I ran into a third party library that is written in a mixture of C/C++ where most of its headers have a .h filename suffix where a .hpp suffix would be more appropriate.
Using this third party library from cgo should be possible since it makes almost no use of the higher level C++ abstractions, but the header files need to be compiled by a C++ compiler, otherwise the compilation process fails.
I can make cgo work by forcing it to use a C++ compiler for C code like this:
env CC=g++ go build
but as soon as I actually start using the library from go code this approach does not work because cgo generates C code which can not be compiled when CC is set as g++. If I only generate the the _cgo_export.c and _cgo_export.h files with:
env CC=g++ go tool cgo
and then manually compile them with gcc, the compilation works fine.
So my question here is about what options I have to tell cgo about which files to compile as C++ files, and which files to compile as C files?
Is there a way to specifically inform cgo about the wrongly named C++ headers and that it should compile only those files with a C++ instead of a C compiler?