-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix some codegen bugs: NIM_BOOL, NIM_STATIC_ASSERT, --passc:-std=... (etc) #13798
fix some codegen bugs: NIM_BOOL, NIM_STATIC_ASSERT, --passc:-std=... (etc) #13798
Conversation
|
7484527
to
b008358
Compare
PTAL
|
We support C89. |
fbbff96
to
dc332a1
Compare
done, that was a simple fix, PTAL |
dc332a1
to
77e8c3d
Compare
77e8c3d
to
161bb43
Compare
friendly ping @Araq |
EVMC adopts the C99 standard, and one of its interfaces uses C99 `bool`. Nim's `bool` uses C `bool` when compiler is in C99 mode (but some default to C89) and Nim version is >= 1.4.6, or always on C++, but those conditions aren't always met. See nim-lang/Nim#13798. Although `sizeof(bool)` is nearly always 1, not always. Some targets use `enum` or `int`, e.g. Apple/Darwin PPC, some 32-bit ARMs. Anyway, it isn't guaranteed to be returned from a function the same way as a integer. So do the right thing and use the C99 `<stdbool.h>` type. Most targets have this header even in C89 mode, and if they don't we can't guarantee EVMC binary compatibility. The `= bool` tells Nim it's semantically compatible with the Nim `bool` type, and the `.importc` part says to use C `bool` in the generated C code. Signed-off-by: Jamie Lokier <[email protected]>
--passc:-std=c++17
(or similar flags) are now honored instead of silently ignored, by putting--passc
options after instead of before the defaultuse correct definition for
NIM_BOOL
in C target. Previous definition was incorrect, asbool
is not guaranteed to be compatible withunsigned char
(could have different sizeof etc); furthermore, it would cause codegen error for C code that uses_Bool
or (afterinclude <stdbool.h>
)bool
note: it's >= C99 but I doubt nim codegen works with < C99; if needed an extra check (or conditional define) can be used
NIM_NIL
is incorrect for c++ < c++11, but fixing it would be hard and maybe not worth it, eg:(requires rebuilding nim with this PR so that
--passc=-std=c++03
is honored)EDIT
links