|
Boost Users : |
From: Mike Wilson (mike_at_[hidden])
Date: 2003-04-22 15:19:19
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
>
> -Ryan
>
> -------------------------------
> "...real recognize real."
> -Rakim
>
> On Mon, 21 Apr 2003, Mike Wilson wrote:
>
> > Hi,
> >
> > There is an application I use that always produces a little endian
binary
> > file.
> > I have written a program to process this file.
> > As my program can port to both little/big endian platforms I have a
#define
> > (LITTLE_ENDIAN_TARGET)
> > acting as a flag for the necessary byte swapping that is needed on the
> > big-endian platforms.
> >
> > I was wondering if there is a better way to do this, so I searched the
Web &
> > boost archives.
> > I found the following code snippet in the boost archives.
> >
> > bool isLittleEndian() {
> > int temp = 1;
> > return (*(char*)&temp) != 0;
> > }
> >
> > which is of some help (eliminating my #define).
> >
> > However, I was wondering if there is a PP or mpl way of testing for
> > endian-ness at compile time.
> >
> > For example, I'd like to do something like the following:
> >
> > const bool IsLittleEndian = ..to be determined automatically..;
> >
> > I've got a gut feeling that I can't do the above at complile time, but
maybe
> > something like Wave may do the job?
> >
> > Thanks for any assistance in this matter.
> >
> > Mike
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