-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
force new enums for pinMode and pinStatus to 8 bits type instead of default int #109
Comments
Hi @JAY-M-ERICSSON , |
Isn't that a C file rather than a C++ header? |
These values should indeed be usable from C as well as C++, so that won't help. However, I think there is limited gain in having e.g. So maybe an alternative fix would be to just do e.g.
This would also address #25 (now also for C code), but again lose the additional type safety that these types were intended to provide... However, I'm afraid that between extra type safety, backward compatibility and single-byte types, we'd have to choose 2... Or, maybe not, it seems you might be able to do this with the (non-standard) |
probably still better to force the type of the enum (as mentioned above)?
it will default to an |
Wait, it seems I misread your proposal. I thought you wanted to switch to C++ If not, maybe an |
Hi I missed your point of C compatibility. You are 100% right. Won’t do. My view is that this is for arduino and the compiler is C++ (and so many underlying libraries are Classes) that we should not worry about support in C (I've not double checked but would assume this is getting compiled with the C++ compiler) That being said, I’m not very supportive of moving this to a type, I don’t think it’s worth all the trouble with so much legacy code around . Even if I’m a big fan of strongly typed variables, The value added is limited |
I've seen
This will let the compiler decide how big the backend storage needs to be for those, and it will default to an int (16 or 32 bit depending on architecture). There is no need for this waste of memory and it prevents also some compiler optimization
I suggest forcing the uint8_t type, 256 values should be plenty to represent a pinMode or a pinStatus..
proposed changes:
but in practice I would vote against getting these changes in production. There is no value added and tons of unwanted consequences for existing code out there to make this worthwhile.
The text was updated successfully, but these errors were encountered: