Hello everybody,
I am in a rabbit hole (don't ask!), and I need to drag some other people with me.
What is the consensus about the most portable way to detect the endianness of a machine/platform? (Ok, we can assume that while running on an ARM the endianness is "fixed" by the OS)
All the best
MA
#x100 will generally do it for me, for the past 50 years. Reads back as a 2-byte stream as 00 01 on little-endian, and 01 00 on big-endian.
But yes, ARM is like Intel, little endian.
- DM
On Feb 4, 2024, at 10:03, Marco Antoniotti marco.antoniotti@unimib.it wrote:
Hello everybody,
I am in a rabbit hole (don't ask!), and I need to drag some other people with me.
What is the consensus about the most portable way to detect the endianness of a machine/platform? (Ok, we can assume that while running on an ARM the endianness is "fixed" by the OS)
All the best
MA
-- Marco Antoniotti, Professor tel. +39 - 02 64 48 79 01 DISCo, Università Milano Bicocca U14 2043 http://dcb.disco.unimib.it http://dcb.disco.unimib.it/ Viale Sarca 336 I-20126 Milan (MI) ITALY
union { int16_t w; int8_t b[2]; } chimera.
chimera x; x.w = 0x100; tes x.b[0]t
On Feb 4, 2024, at 11:48, David McClain dbm@refined-audiometrics.com wrote:
#x100 will generally do it for me, for the past 50 years. Reads back as a 2-byte stream as 00 01 on little-endian, and 01 00 on big-endian.
But yes, ARM is like Intel, little endian.
- DM
On Feb 4, 2024, at 10:03, Marco Antoniotti marco.antoniotti@unimib.it wrote:
Hello everybody,
I am in a rabbit hole (don't ask!), and I need to drag some other people with me.
What is the consensus about the most portable way to detect the endianness of a machine/platform? (Ok, we can assume that while running on an ARM the endianness is "fixed" by the OS)
All the best
MA
-- Marco Antoniotti, Professor tel. +39 - 02 64 48 79 01 DISCo, Università Milano Bicocca U14 2043 http://dcb.disco.unimib.it http://dcb.disco.unimib.it/ Viale Sarca 336 I-20126 Milan (MI) ITALY
Use CFFI, see which of #+little-endian or #+big-endian is enabled. Assume you're not on a nuxi-endian machine.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org “Compulsory apologies mostly train children to say things they don’t mean — that is, to lie.” ― Alfie Kohn, ‘Unconditional Parenting’
On Sun, Feb 4, 2024 at 12:04 PM Marco Antoniotti marco.antoniotti@unimib.it wrote:
Hello everybody,
I am in a rabbit hole (don't ask!), and I need to drag some other people with me.
What is the consensus about the most portable way to detect the endianness of a machine/platform? (Ok, we can assume that while running on an ARM the endianness is "fixed" by the OS)
All the best
MA
-- Marco Antoniotti, Professor tel. +39 - 02 64 48 79 01 DISCo, Università Milano Bicocca U14 2043 http://dcb.disco.unimib.it Viale Sarca 336 I-20126 Milan (MI) ITALY
Akshully, CFFI gets the information from trivial-features.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org “Ad hominem is not valid as an argument, but often valid as a conclusion — or indeed as a premise — in which case: avoid further argument.”
On Sun, Feb 4, 2024 at 1:52 PM Faré fahree@gmail.com wrote:
Use CFFI, see which of #+little-endian or #+big-endian is enabled. Assume you're not on a nuxi-endian machine.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org “Compulsory apologies mostly train children to say things they don’t mean — that is, to lie.” ― Alfie Kohn, ‘Unconditional Parenting’
On Sun, Feb 4, 2024 at 12:04 PM Marco Antoniotti marco.antoniotti@unimib.it wrote:
Hello everybody,
I am in a rabbit hole (don't ask!), and I need to drag some other people with me.
What is the consensus about the most portable way to detect the endianness of a machine/platform? (Ok, we can assume that while running on an ARM the endianness is "fixed" by the OS)
All the best
MA
-- Marco Antoniotti, Professor tel. +39 - 02 64 48 79 01 DISCo, Università Milano Bicocca U14 2043 http://dcb.disco.unimib.it Viale Sarca 336 I-20126 Milan (MI) ITALY
The snide, unhelpful response to this question might be this:
Why do you care, big or little?
That you care indicates you are doing something you shouldn't do.
Of course, sometimes you are forced to do something you shouldn't do because somebody else has already done something he shouldn't do.
On Sun, Feb 4, 2024 at 10:53 AM Faré fahree@gmail.com wrote:
Use CFFI, see which of #+little-endian or #+big-endian is enabled. Assume you're not on a nuxi-endian machine.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org “Compulsory apologies mostly train children to say things they don’t mean — that is, to lie.” ― Alfie Kohn, ‘Unconditional Parenting’
On Sun, Feb 4, 2024 at 12:04 PM Marco Antoniotti marco.antoniotti@unimib.it wrote:
Hello everybody,
I am in a rabbit hole (don't ask!), and I need to drag some other people
with me.
What is the consensus about the most portable way to detect the
endianness of a machine/platform? (Ok, we can assume that while running on an ARM the endianness is "fixed" by the OS)
All the best
MA
-- Marco Antoniotti, Professor tel. +39 - 02 64 48 79 01 DISCo, Università Milano Bicocca U14 2043 http://dcb.disco.unimib.it Viale Sarca 336 I-20126 Milan (MI) ITALY