-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Define magic numbers as integer constants (#1518) #1520
Define magic numbers as integer constants (#1518) #1520
Conversation
303322b
to
8cd145e
Compare
@imaami |
It isn't currently a practical problem as far as compiler behavior is concerned. My first conclusion was incorrect, all three major compilers (GCC, Clang, MSVC) generate the same 4-byte sequence from the relevant multibyte character literals ( The only "problem" left on the table is the implementation-defined nature of multibyte character literals and how a compiler is allowed to represent one in memory. Nothing in the C or C++ standards mandates a specific order for the constituent bytes. So although in practice this issue is only a theoretical one as of now, defining the magic numbers as integer literals would still be a more robust alternative. |
Oh, and there's also another thing: the language standards define the type of a multibyte character literal as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess these also have to be updated:
How did I miss these? :D I'll get on it and rebase to the current master too. |
There is also one for the lora files: |
8cd145e
to
2be4e54
Compare
The underlying representation of multibyte character literals is implementation-defined. This could, at least in principle, cause cross-build data export/import issues independent of endianness. Define magic numbers as integer literals to be on the safe side. Signed-off-by: Juuso Alasuutari <[email protected]>
2be4e54
to
c69f0cd
Compare
Wow, thanks for the quick approval. :) |
The underlying representation of multibyte character literals is
implementation-defined. This could, at least in principle, cause
cross-build data export/import issues independent of endianness.
Define magic numbers as integer literals to be on the safe side.