Skip to content
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

Check code and identify compiler extensions vs. standard C and state requirements #95

Open
prajnoha opened this issue Mar 24, 2021 · 0 comments

Comments

@prajnoha
Copy link
Member

Starting this as a consequence of discussion from PR #93.

Ben: But this makes me wonder, is typedef enum { KV_STORE_VALUE_INT_ALLOC = UINT32_C(0x00000001), } kv_store_value_int_flags_t; guaranteed to be 32 bits? I thought enum size was compiler dependent. If it's not guaranteed to be at least 32 bits, struct kv_store_value needs to go back to explicitly declaring the size of int_flags and ext_flags. Otherwise, value->data might not be aligned for storing iov structures.

Me: ...from that, the only thing that standard assures is that the members are compatible with int, and that one is 16 bits at least by standard. From that, I understand that if I wanted the members of enum to be of long int or long long int type, that is completely in the hands of the compiler if it decides to support that or not.

If we wanted to be sure, we shouldn't be using any different type than the one representable as int in enums, otherwise, this is all in the hands of the compiler if it supports it or not.

Now, we may use some of the compiler extensions throughout the code already, so if we expect (or know it works with) certain compilers already, we need to state that as requirement in the documentation somewhere. If we comply with standard C fully, then OK, but then the enums must be fixed.

@prajnoha prajnoha mentioned this issue Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant