From: Michael Date: Tue, 31 Jul 2018 20:06:14 GMT Subject: Re: Is detecting endianness at compile-time unworkable? Message-ID: <325d1a6c-276a-9ffa-f9c5-72cbdecb6175@felt.demon.nl> In-Reply-To: <87sh3ztrcb.fsf@evledraar.gmail.com> On 31/07/2018 16:25, Ævar Arnfjörð Bjarmason wrote: > ...the real trick is using these macros outside of GCC / glibc and on > older GCC versions. See the github link above, you basically end up with > a whitelist of how it looks on different systems / compilers. Sometimes > both are defined, sometimes only both etc. > > It can be done, but as that code shows it's somewhat complex macro soup > to get right. FYI - the gcc I was using is 4.7.4. And, the reason I suggest the test for both not being defined is so that 'make' stops and whoever is running make just sets one or the other. Let them 'file a bug' When they come with a compiler that does not work - and find out what could be used. For example, _AIX is the same as _BIG_ENDIAN. In the meantime, the code to test is simple. Either one of _BIG_ENDIAN or _LITTLE_ENDIAN is provided by the compiler or the builder supplies one of the two using CFLAGS. I assume there is also a "undefine" flag, maybe -U - so hopefully a -U and a -D combination could be used for cross-compiling. re: my mailer blocking things - it would only be for this list, as other lists come through with no extra work from me. At least I am not aware of anything special I could do.