dropbox / djinni

A tool for generating cross-language type declarations and interface bindings.
Apache License 2.0
2.88k stars 488 forks source link

Suppress constexpr members declarations #374

Open GTValentine opened 6 years ago

GTValentine commented 6 years ago

There's no option to suppress constexpr members declarations. For this .djinni file:

bar = record
{
  const foo: i32 = 42;
}

Two files will be generated:

//.hpp
struct Bar final 
{
    static constexpr int32_t FOO = 42;
}

and

//.cpp
int32_t const Bar::FOO;

MSVC with c++17 enabled though frowns upon that:

warning C5041: 'FOO': out-of-line definition for constexpr static data member is not needed and is deprecated in C++17.

We're compiling with /WX (warning treated as errors) so this broke our build.

Please provide an option to not generate the declarations.

artwyman commented 6 years ago

Making this optional seems like a reasonable thing for Djinni to do. Is the definition required at C++11 level? If so we couldn't eliminate it entirely while maintaining compatibility. At any rate, feel free to phrase your request in the form of a Pull Request. 😄

Meanwhile, you can likely work around this by tweaking the build options for generated code compared to your own code. I've frequently had to do that for 3rd-party code, which generally isn't as warning-clean as we want our internal code to be.