Hi!
I tried creating C binding library using cgo
on Windows as follows:
go build -o libexample.a -buildmode=c-archive
This step generates libexample.h
& libexample.a
.
When I copy these 2 in the folder where my C++ code exists, then the C++ code compiles successfully
However, when I copy these 2 files on the same C++ code folder on MacOS, then on compilation of C++ code, I get this error:
In file included from ..........cpp:9:
cgo-gcc-export-header-prolog:106:8: error: unknown type name '_Bool'
extern _Bool function1();
^
cgo-gcc-export-header-prolog:186:8: error: unknown type name '_Bool'
extern _Bool function2();
^
These 2 functions are defined in the .go files as follows:
//export function1
func function1() C.bool {
.
.
.
}
//export function2
func function2() C.bool {
.
.
.
}
The C.bool
return type generates _Bool
return type instead of bool
on using cgo
The temporary fix (i.e. manually changing _Bool
to bool
in both these declarations in the generated .h file) works, but is not a proper fix as I need to regenerate the libexample.h library with some custom functions
Kindly suggest a proper fix.
Thanks