cbindgen icon indicating copy to clipboard operation
cbindgen copied to clipboard

C and C++ in same header file?

Open vanillajonathan opened this issue 2 years ago • 2 comments

In other C files I've seen things like:

#ifdef __cplusplus
extern "C" {
#endif

void hello_world(char *greeting);

#ifdef __cplusplus
}
#endif

Example: https://github.com/xiallc/PixieSDK/blob/master/sdk/include/pixie16/pixie16.h

Maybe cbindgen could do that?

vanillajonathan avatar Feb 18 '23 16:02 vanillajonathan

I believe the cpp_compat flag does what you're suggesting?

comp500 avatar Feb 19 '23 04:02 comp500

My bad. Yes it does!

Hmm, why isn't this enabled by default? And why isn't this mentioned in the template.toml file?

vanillajonathan avatar Feb 19 '23 11:02 vanillajonathan

It's in docs.md tho... But yeah would take a patch to mention in template.toml. As for defaults, mostly historical I believe.

emilio avatar Apr 15 '24 01:04 emilio

Would it be feasible to change the defaults to enable cpp_compat?

vanillajonathan avatar Apr 15 '24 13:04 vanillajonathan