mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
cgo: add support for #define constants
These are converted to Go constants where possible.
This commit is contained in:
committed by
Ron Evans
parent
eb0ce8a298
commit
99587fe073
Vendored
+4
@@ -18,6 +18,10 @@ func main() {
|
||||
var y C.longlong = -(1 << 40)
|
||||
println("longlong:", y)
|
||||
println("global:", C.global)
|
||||
println("defined ints:", C.CONST_INT, C.CONST_INT2)
|
||||
println("defined floats:", C.CONST_FLOAT, C.CONST_FLOAT2)
|
||||
println("defined string:", C.CONST_STRING)
|
||||
println("defined char:", C.CONST_CHAR)
|
||||
var ptr C.intPointer
|
||||
var n C.int = 15
|
||||
ptr = C.intPointer(&n)
|
||||
|
||||
Vendored
+7
@@ -10,6 +10,13 @@ int doCallback(int a, int b, binop_t cb);
|
||||
typedef int * intPointer;
|
||||
void store(int value, int *ptr);
|
||||
|
||||
# define CONST_INT 5
|
||||
# define CONST_INT2 5llu
|
||||
# define CONST_FLOAT 5.8
|
||||
# define CONST_FLOAT2 5.8f
|
||||
# define CONST_CHAR 'c'
|
||||
# define CONST_STRING "defined string"
|
||||
|
||||
// this signature should not be included by CGo
|
||||
void unusedFunction2(int x, __builtin_va_list args);
|
||||
|
||||
|
||||
Vendored
+4
@@ -4,6 +4,10 @@ myint: 3 5
|
||||
myint size: 2
|
||||
longlong: -1099511627776
|
||||
global: 3
|
||||
defined ints: 5 5
|
||||
defined floats: +5.800000e+000 +5.800000e+000
|
||||
defined string: defined string
|
||||
defined char: 99
|
||||
15: 15
|
||||
25: 25
|
||||
callback 1: 50
|
||||
|
||||
Reference in New Issue
Block a user