-
Notifications
You must be signed in to change notification settings - Fork 301
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
[Core] Fix more C99 compliance issues #118
[Core] Fix more C99 compliance issues #118
Conversation
Would you mind also fixing MSVC C99 compliance issues in your PR ? #ifdef _MSC_VER
#define CLAY_PACKED_ENUM __pragma(pack(push, 1)) enum __pragma(pack(pop))
#else
#define CLAY_PACKED_ENUM enum __attribute__((__packed__))
#endif |
I really can't figure out why the GCC test is failing :-(. I can reproduce it, but I can't figure out which of the changes in this PR are causing it. |
From what i'm reading, it seems like |
I've figured out what the issue is, but unfortunately it's not easy to fix... I'll have a think and come back on this soon. |
Would you mind expanding on what the issue is ? |
30f2877
to
3e8688e
Compare
This fixes almost all the C99 compliance issues in the implementation of Clay. Now the only issues remaining are: - ##__VA_ARGS__, which isn't easy to solve without switching to C23. - Defining a struct within offsetof to get the alignment of a type, which also isn't easy to solve without switching to C11. - A number of times that signed integers are compared with unsigned integers, which will need some rethinking of all the types for lengths and indices etc. - Some strangeness with the CLAY_SIZING_FIT and CLAY_SIZING_GROW macros, which don't compile without specifying -std=gnu99 rather than -std=c99 for some reason.
To do this, we create a new struct for every new type Clay creates, which contains the char and the type, to get the offset.
3e8688e
to
1a08598
Compare
GCC throws this warning. It's not an issue, but fixing it properly will probably need API changes, so *temporarily* just disable the error.
It's to do with the fact that we're now initialising the structs with My general idea with removing the |
Confirming for posterity that we're going to move forward assuming a compiler that has support for |
We will tackle this in a separate PR so we can get this over the line! |
This fixes almost all the C99 compliance issues in the implementation of Clay.
Now the only issues remaining are:
##__VA_ARGS__
(and related), which isn't easy to solve without switching to C23.offsetof
to get the alignment of a type, which also isn't easy to solve without switching to C11. (Solved using macro magic)CLAY_SIZING_FIT
andCLAY_SIZING_GROW
macros, which don't compile without specifying-std=gnu99
rather than-std=c99
for some reason.