mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 03:27:48 +00:00
cgo: support builtin #include headers
Add support for header files bundled with the compiler by copying them into the release tarball.
This commit is contained in:
committed by
Ron Evans
parent
d396abb690
commit
2f2d62cc0c
Vendored
+3
-2
@@ -1,8 +1,8 @@
|
||||
#include "main.h"
|
||||
|
||||
int global = 3;
|
||||
_Bool globalBool = 1;
|
||||
_Bool globalBool2 = 10; // test narrowing
|
||||
bool globalBool = 1;
|
||||
bool globalBool2 = 10; // test narrowing
|
||||
float globalFloat = 3.1;
|
||||
double globalDouble = 3.2;
|
||||
_Complex float globalComplexFloat = 4.1+3.3i;
|
||||
@@ -11,6 +11,7 @@ _Complex double globalComplexLongDouble = 4.3+3.5i;
|
||||
char globalChar = 100;
|
||||
void *globalVoidPtrSet = &global;
|
||||
void *globalVoidPtrNull;
|
||||
int64_t globalInt64 = -(2LL << 40);
|
||||
collection_t globalStruct = {256, -123456, 3.14, 88};
|
||||
int globalStructSize = sizeof(globalStruct);
|
||||
short globalArray[3] = {5, 6, 7};
|
||||
|
||||
Vendored
+1
@@ -43,6 +43,7 @@ func main() {
|
||||
println("char match:", C.globalChar == 100)
|
||||
var voidPtr unsafe.Pointer = C.globalVoidPtrNull
|
||||
println("void* match:", voidPtr == nil, C.globalVoidPtrNull == nil, (*C.int)(C.globalVoidPtrSet) == &C.global)
|
||||
println("int64_t match:", C.globalInt64 == C.int64_t(-(2<<40)))
|
||||
|
||||
// complex types
|
||||
println("struct:", C.int(unsafe.Sizeof(C.globalStruct)) == C.globalStructSize, C.globalStruct.s, C.globalStruct.l, C.globalStruct.f)
|
||||
|
||||
Vendored
+7
-3
@@ -1,3 +1,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef short myint;
|
||||
int add(int a, int b);
|
||||
typedef int (*binop_t) (int, int);
|
||||
@@ -27,10 +30,10 @@ void unionSetShort(short s);
|
||||
void unionSetFloat(float f);
|
||||
void unionSetData(short f0, short f1, short f2);
|
||||
|
||||
// test globals
|
||||
// test globals and datatypes
|
||||
extern int global;
|
||||
extern _Bool globalBool;
|
||||
extern _Bool globalBool2;
|
||||
extern bool globalBool;
|
||||
extern bool globalBool2;
|
||||
extern float globalFloat;
|
||||
extern double globalDouble;
|
||||
extern _Complex float globalComplexFloat;
|
||||
@@ -39,6 +42,7 @@ extern _Complex double globalComplexLongDouble;
|
||||
extern char globalChar;
|
||||
extern void *globalVoidPtrSet;
|
||||
extern void *globalVoidPtrNull;
|
||||
extern int64_t globalInt64;
|
||||
extern collection_t globalStruct;
|
||||
extern int globalStructSize;
|
||||
extern short globalArray[3];
|
||||
|
||||
Vendored
+1
@@ -16,6 +16,7 @@ complex double: (+4.200000e+000+3.400000e+000i)
|
||||
complex long double: (+4.300000e+000+3.500000e+000i)
|
||||
char match: true
|
||||
void* match: true true true
|
||||
int64_t match: true
|
||||
struct: true 256 -123456 +3.140000e+000
|
||||
array: 5 6 7
|
||||
union: true
|
||||
|
||||
Reference in New Issue
Block a user