-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from Yoitsumi/topic/fix-varargs
Fix c-style varargs accepting only single parameter
- Loading branch information
Showing
4 changed files
with
30 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import scalanative.native._, stdlib._, stdio._ | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
println("Hello, world!") | ||
val W = 800 | ||
val H = 600 | ||
fprintf(stdout, c"P3\n%d %d\n%d\n", W, H, 255) | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
unit-tests/src/main/scala/scala/scalanative/native/CInteropSuite.scala
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,15 @@ | ||
package scala.scalanative.native | ||
|
||
import stdio._ | ||
|
||
object CInteropSuite extends tests.Suite { | ||
|
||
test("varargs") { | ||
val buff = stackalloc[CChar](64) | ||
sprintf(buff, c"%d %d %d", 1, 2, 3) | ||
for ((c, i) <- "1 2 3".zipWithIndex) { | ||
assert(buff(i) == c) | ||
} | ||
} | ||
|
||
} |
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