Test __GLIBC__ for endian.h availability #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
endian.hheader, as well as macros and functions declared in it, are not a part of Linux, but really provided by the GNU C Library (GLIBC), soendianness.hshould test the__GLIBC__macro instead, for this feature.But since the
__GLIBC__macro is usually not predefined by compiler, but rather in GLIBC's ownfeatures.honly, there is a small chance that it didn't get defined by the timeendianness.hget included; for example the user may be includingendianness.hbefore any GLIBC headers. The workaround I considered is keeping the original__linuxmacro test, however this is not ideal because it made an assumption that all other C library implementations for Linux must support this nonstandardendian.h, in a GLIBC-compatible way.This change enables using GLIBC
endian.hto detect byte-order on non-Linux-based GNU systems, where compiler built-in__BYTE_ORDER__isn't available for any reason.