mozilla / cbindgen

A project for generating C bindings from Rust code
Mozilla Public License 2.0
2.27k stars 294 forks source link

cpp_compat option ignores namespace #391

Open adamski opened 4 years ago

adamski commented 4 years ago

The following config

language = "C"
cpp_compat = true
include_version = false
namespace = "acme"

Results in no namespace being included in the generated header within the #ifdef __cplusplus sections.

I would expect something like this to be generated:

#ifdef __cplusplus
namespace acme {
extern "C" {
#endif // __cplusplus

void print_hello(void);

#ifdef __cplusplus
} // extern "C"
} // namespace acme
#endif // __cplusplus
emilio commented 4 years ago

I don't see related discussion in https://github.com/eqrion/cbindgen/pull/349, so thus no reason not to do this I guess. This is probably pretty easy to fix.