Closed mikejsavage closed 1 month ago
Thanks for opening this one! I had been putting it off until the core implementation stabilized, but we can definitely begin to address each of these
It doesn't support C designated initializers
AFAIK there should be a way at the very least for the library syntax to be compatible with both C99 designated initializers as well as C++20 designated initializers. C++20 is much more picky but should be roughly syntax equivalent if the members are in declaration order
It doesn't support attribute((packed))__
Yep nice, should be able to replace this with a #ifdef
of msvc and swap out for whatever equivalent to size enums into 1 byte
It doesn't like CLAYALIGNMENT, #define CLAYALIGNMENT(type) _Alignof(type) works though
This one should be reasonably easy to #ifdef
in as well.
As for supporting non C99 versions of C, the best way forward might be to compile clay as a lib and write a second set of macros / declarations that are compatible with C11 etc... 🤔
From my investigations so far, it looks like I'm probably going to be able to get it in line with MSVC C++20. Microsoft flavoured C though, might not be possible. I don't think I'm willing to drop to C89 for the whole library just to support those versions on MSVC. Probably would be best in that case to just compile as a lib and link in 👍
Follow up: Successfully compiling as C++20 with MSVC here https://github.com/nicbarker/clay/actions/runs/11083013067/job/30796749136 😁
I'm going to mark this as completed for now, when clay stabilizes a little more we can reopen a discussion into whether it's worth dropping to C89 for the library itself in order to support C11 and beyond 🙂
Yep I've been messing with clay in our engine, it seems fine so far but I haven't done much with it yet
@mikejsavage Great, please let me know if you end up building something with it!
Clay currently doesn't compile under MSVC because:
__attribute__((packed))__
CLAY__ALIGNMENT
,#define CLAY__ALIGNMENT(type) _Alignof(type)
works though1 and 2 are not very nice to solve with Microsoft flavoured C, although I will say all of these have direct solutions if you don't mind C++