cgo: support function-like macros

This is needed for code like this:

    #define __WASI_ERRNO_INVAL (UINT16_C(28))
    #define EINVAL __WASI_ERRNO_INVAL
This commit is contained in:
Ayke van Laethem
2024-11-06 13:46:49 +01:00
committed by Ron Evans
parent c4867c8743
commit e12da15f7d
8 changed files with 214 additions and 46 deletions
+13
View File
@@ -3,13 +3,26 @@ package main
/*
#define foo 3
#define bar foo
#define unreferenced 4
#define referenced unreferenced
#define fnlike() 5
#define fnlike_val fnlike()
#define square(n) (n*n)
#define square_val square(20)
#define add(a, b) (a + b)
#define add_val add(3, 5)
*/
import "C"
const (
Foo = C.foo
Bar = C.bar
Baz = C.referenced
fnlike = C.fnlike_val
square = C.square_val
add = C.add_val
)