cmajor-lang / cmajor

The Cmajor public repository
https://cmajor.dev
Other
534 stars 31 forks source link

Guarantee representation of Result type #70

Closed 0xchase closed 3 months ago

0xchase commented 3 months ago

Hello,

In cmaj_Result.h, it's probably appropriate to guarantee the representation of the Result type since the C++ spec (to my knowledge), does not specify how enums should be sized and it therefore may vary between compilers or with different compiler flags. What I have in mind is something like:

enum class Result: int16_t
{
...

Or whatever size you'd prefer. Thanks for all your amazing work!

cesaref commented 3 months ago

Yeah, that's a good point - i'll set it to int32_t. I think in practice, since we're using this as a return type the calling convention will keep this in a register, so it will actually not matter what type we specify, but best not to leave anything to chance :)

I'll include this change in the next update.