-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
WIP: Introduce (conditional) C23 fixed underlying types to enums #1417
base: master
Are you sure you want to change the base?
Conversation
6b7361b
to
42e0bba
Compare
This will break the ABI backward compatibility. I don't think libusb can afford this change at all... At most - this can be optional config to be enabled at build time explicitly (and disabled by default) to be used by those who really need it explicitly in ther projects/application. But I can't imagine a scenario what that is required by any of the sane use-cases. |
Only if the size/sign/type is actually changed (as opposed to merely being stated explicitly). And for private enums, we can change the ABI/API, can we not? For public enums, then yes, I agree we need to be very careful about changing them |
Yes, that shold not harm.
Unless stated explicitly (in C23), the And as far as this PR suggests - many public-declared enums are declared to be other (smaller) than To be honest I don't really get the point of explicilty specifying the enum type to be |
@tormodvolden do you happen to have an oppinion on this one? |
Here's some details: https://en.cppreference.com/w/c/language/enum
It's quite helpful when converting between an enum and a raw integer type (which libusb does a lot). It helps the compiler warn about signed/unsigned mismatches, and size mismatches. For example, struct libusb_device_descriptor {
...
uint8_t bDescriptorType;
... By tagging the enum in this way it 1) acts like documentation 2) the compiler can ensure values do not exceed what's expected. I agree there are compatibility concerns. But for me, opting into a new language version (with |
That's a huge compatibility break :) To have it as an improvement - it has to be a build/configuration option that has to be explicitly enabled, rather than depend on the compiler capabilities. |
I took a stab at specifying some of the sizes, based on how they are used, but it's all provisional, and there may be backwards compatibility concerns...
I took a stab at specifying some of the sizes, based on how they are used, but it's all provisional, and there may be backwards compatibility concerns...