cgo: implement prefix parsing

This implements expressions such as "-5" and "-5 - 2", in other words,
negative numbers.
This commit is contained in:
Ayke van Laethem
2021-05-20 16:43:22 +02:00
committed by Ron Evans
parent 70f8eeaca0
commit 711889bc3f
4 changed files with 19 additions and 0 deletions
+2
View File
@@ -6,6 +6,7 @@ int fortytwo(void);
int mul(int, int);
#include <string.h>
#cgo CFLAGS: -DSOME_CONSTANT=17
#define someDefine -5 + 2 * 7
*/
import "C"
@@ -26,6 +27,7 @@ func main() {
println("defined floats:", C.CONST_FLOAT, C.CONST_FLOAT2)
println("defined string:", C.CONST_STRING)
println("defined char:", C.CONST_CHAR)
println("defined expr:", C.someDefine)
var ptr C.intPointer
var n C.int = 15
ptr = C.intPointer(&n)
+1
View File
@@ -8,6 +8,7 @@ defined ints: 5 5
defined floats: +5.800000e+000 +5.800000e+000
defined string: defined string
defined char: 99
defined expr: 9
15: 15
25: 25
callback 1: 50