forked from vlang/v
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v: improve C var args interop, allow for
fn f(some int, ...) {
(vla…
- Loading branch information
Showing
12 changed files
with
108 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@[typedef] | ||
struct C.va_list {} | ||
|
||
fn C.va_start(voidptr, voidptr) | ||
fn C.va_end(voidptr) | ||
|
||
fn C.vfprintf(&C.FILE, &char, C.va_list) int | ||
|
||
fn C.printf(&char, ...) | ||
|
||
fn t2(fmt voidptr, ...) { | ||
ap := C.va_list{} | ||
C.va_start(ap, fmt) | ||
C.vfprintf(C.stderr, fmt, ap) | ||
C.va_end(ap) | ||
} | ||
|
||
fn main() { | ||
a := 1 | ||
b := 2.5 | ||
t2(c'%s : %d : %.2f\n', c'foo', a, b) | ||
C.printf(c'%s\n', c'foo') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VV_LOCAL_SYMBOL void main__t2(voidptr fmt, ... ); | ||
VV_LOCAL_SYMBOL void main__t2(voidptr fmt, ... ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
foo : 1 : 2.50 | ||
foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@[typedef] | ||
struct C.va_list {} | ||
|
||
fn C.va_start(voidptr, voidptr) | ||
fn C.va_end(voidptr) | ||
|
||
fn C.vfprintf(&C.FILE, &char, C.va_list) int | ||
|
||
fn C.printf(&char, ...) | ||
|
||
fn t2(fmt voidptr, ...) { | ||
ap := C.va_list{} | ||
C.va_start(ap, fmt) | ||
C.vfprintf(C.stdout, fmt, ap) | ||
C.va_end(ap) | ||
} | ||
|
||
fn main() { | ||
a := 1 | ||
b := 2.5 | ||
t2(c'%s : %d : %.2f\n', c'foo', a, b) | ||
C.printf(c'%s\n', c'foo') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters