cgo: support full cgo tags

This commit is contained in:
Li Jie
2024-11-15 12:24:46 +08:00
parent a64f4219e9
commit 9f0b3963cb
7 changed files with 344 additions and 50 deletions

View File

@@ -1,6 +1,11 @@
package main
/*
#cgo windows,!amd64 CFLAGS: -D_WIN32
#cgo !windows CFLAGS: -D_POSIX
#cgo windows,amd64 CFLAGS: -D_WIN64
#cgo linux,amd64 CFLAGS: -D_LINUX64
#cgo !windows,amd64 CFLAGS: -D_UNIX64
#include <stdio.h>
#include "foo.h"
typedef struct {
@@ -50,6 +55,21 @@ static void test_macros() {
#ifdef BAR
printf("BAR is defined\n");
#endif
#ifdef _WIN32
printf("WIN32 is defined\n");
#endif
#ifdef _POSIX
printf("POSIX is defined\n");
#endif
#ifdef _WIN64
printf("WIN64 is defined\n");
#endif
#ifdef _LINUX64
printf("LINUX64 is defined\n");
#endif
#ifdef _UNIX64
printf("UNIX64 is defined\n");
#endif
}
*/
import "C"