mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
cgo: add support for C.int, c.uint, etc
This commit is contained in:
Vendored
+4
@@ -4,6 +4,10 @@ int32_t fortytwo() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
int add(int a, int b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int32_t mul(int32_t a, int32_t b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -5,12 +5,16 @@ package main
|
||||
int32_t fortytwo(void);
|
||||
int32_t mul(int32_t a, int32_t b);
|
||||
typedef int32_t myint;
|
||||
int add(int a, int b);
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func main() {
|
||||
println("fortytwo:", C.fortytwo())
|
||||
println("mul:", C.mul(C.int32_t(3), 5))
|
||||
println("add:", C.add(C.int(3), 5))
|
||||
var x C.myint = 3
|
||||
println("myint:", x, C.myint(5))
|
||||
var y C.longlong = -(1 << 40)
|
||||
println("longlong:", y)
|
||||
}
|
||||
|
||||
Vendored
+2
@@ -1,3 +1,5 @@
|
||||
fortytwo: 42
|
||||
mul: 15
|
||||
add: 8
|
||||
myint: 3 5
|
||||
longlong: -1099511627776
|
||||
|
||||
Reference in New Issue
Block a user