nanopb icon indicating copy to clipboard operation
nanopb copied to clipboard

generator: remove ifdef __cplusplus on enum sizes

Open jaskij opened this issue 1 year ago • 3 comments

While this does not solve #961 completely, it will make the compiler error when sized enums are supported.

I experimented somewhat with adding a preprocessor check, but it seems that GCC extends enum sizes to older C standards, since the enum_sizes test passes without it and fails to compile when I add that.

Yup, seems like GCC extends this extension to all versions of C.

This will absolutely break some builds, but at least it will be broken builds instead of faulty software.

jaskij avatar Jul 19 '24 13:07 jaskij

Looking around: this is supported as an extension for all C standards since GCC 13, and clang in the 2021 timeframe. ARM GNU Toolchain 13 was released last year.

I am not entirely sure how to modify test scripts and/or CI to actually have the CI pass.

jaskij avatar Jul 19 '24 13:07 jaskij

I wonder if it is the -ansi that makes GCC not like it in the test case. The compiler options could be modified for that test case like is done in anonymous_oneof/SConscript

I wonder whether MSVC supports this.

PetteriAimonen avatar Jul 19 '24 18:07 PetteriAimonen

I wonder if it is the -ansi that makes GCC not like it in the test case.

That, and the compiler version. Best I can tell, this was added in GCC 13, possibly 12, and your CI runs on Ubuntu 20.04. Unless you're setting up a non-default compiler, that means GCC 9.

jaskij avatar Jul 19 '24 21:07 jaskij

I think this is obsoleted by b34a649c524

PetteriAimonen avatar Sep 19 '24 12:09 PetteriAimonen