Open e-kayrakli opened 2 weeks ago
I'd probably head in the direction you describe.
However I'd like to point out an alternative, which is to put the extern "C"
wherever the header file is included, e.g. for users to write:
extern "C" {
#include "my-chapel-generated-header.h"
}
The reasons that I think putting this inside the header (as you describe) is probably better are:
extern "C"
.That approach doesn't work -- at least for the case I am working with. The header we generate also includes things like stdchpl.h
, which down the line could include things like atomics and some GPU support code etc where we need C++ linkage. So, doing what you suggest results in other issues coming from the Chapel runtime.
There could be a way out of it; this was my experience after a quick attempt.
Compiling with
--library
results in generating a header file among others. If you want to use this mode with GPU support, you'd typically want to compile your application in C++ mode. But you can't use Chapel functions with C++ linkage. So, the header we generate in this mode must have:and the corresponding closing brace at the end.
Without it, we get undefined reference for each Chapel-based symbol.
Note that this is probably a preliminary requirement for calling Chapel from C++ without GPU support as well.