Open fangerer opened 2 years ago
Would adding
#ifdef __cplusplus
extern "C" {
#endif
blocks to the relevant .c
files help at all?
Unfortunately, this does not help (just tried it out).
Unfortunately, this does not help (just tried it out).
Pity! Thanks for trying it out.
We should perhaps remove the extern "C"
blocks in ctx_*.c
files. I searched around and afaics it just disables names mangling, but the C++ semantics stays the same. I'd say that compiling those files with C++ compiler is just not supported. We should try to keep the header files, especially the inline functions, in some common subset of C and C++ if possible though.
Right now, we are adding source files
argparse.c
,buildvalue.c
, andhelpers.c
to the source file list of the HPy extension to be built and then they are compiled together with the extension's sources.We do so because the goal is that the helpers binary code should be in the HPy extension's library. While this works in most cases, we recently discovered a problem with that strategy on Mac (using LLVM toolchain). The extension was written in C++ and added:
The extension failed to build
argparse.c
with following error:IMO, the underlying issue is that we are building these sources with the flags of the target. I think we should build them in the same way as we do with the rest of HPy. So, I suggest that we build an archive for the helpers and statically link them into the extension.
Optionally, if someone really wants to compile the helpers with the extension, we can provide an option to do so.