Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2003-04-22 20:48:12


"Mike Wilson" <mike_at_[hidden]> writes:

> Thanks for that - I'll look into it.
>
> ----- Original Message -----
> From: "Ryan Barrett" <rbarrett_at_[hidden]>
> Newsgroups: gmane.comp.lib.boost.user
> Sent: Monday, April 21, 2003 10:48 PM
> Subject: Re: Test for endian using MPL or PP(Wave?)
>
>
>> check out boost's template metaprogramming library...i won't guarantee
>> anything, but you might be able to contort it to do what you need.
>>
>> http://boost.org/libs/mpl/doc/index.html

Don't bother. Endian-ness is fundamentally a property of memory
layout. You can't discover anything about the layout of bits in
memory at compile-time (and certainly not using the preprocessor),
since you can't dereference a pointer at compile-time. The only way
to discover endian-ness is to write an integer type to memory and read
it back out as a sequence of chars.

Of course, some platforms supply headers which will tell you about
their endian-ness...

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net