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

Potential endianness detection problem #71

Closed
miloyip opened this issue Jul 13, 2014 · 2 comments · Fixed by #74
Closed

Potential endianness detection problem #71

miloyip opened this issue Jul 13, 2014 · 2 comments · Fixed by #74
Labels
Milestone

Comments

@miloyip
Copy link
Collaborator

miloyip commented Jul 13, 2014

Upstream issue https://code.google.com/p/rapidjson/issues/detail?id=100

Currently Endianness is very important in Value because it uses this for aligning 32-bit and 64-bit integer, in order to implement "no overhead integer conversion".

This "optimization" depends on the RAPIDJSON_ENDIAN macro. Currently it has assumes little endian if gcc __BYTE_ORDER__ is not defined. This is error-prone.

Several potential fixes:

  1. Better endianness detection with more compilers.
  2. If unable to detect, fail to compile and ask user to define the macro explicitly.
  3. Automatic validation of endianness in compile-time or run-time.

Shall check how other cross-platform libraries deal with this issue.

@miloyip miloyip added this to the v1.0 Beta milestone Jul 13, 2014
@pah
Copy link
Contributor

pah commented Jul 13, 2014

Boost has an implementation:

Btw, shouldn't it be __BYTE_ORDER (without trailing underscores)?

@miloyip
Copy link
Collaborator Author

miloyip commented Jul 13, 2014

According to https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
__BYTE_ORDER__ is a predefined macro.

Seems __BYTE_ORDER is defined by some endian.h?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants