You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: