------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1049

Gertjan Halkes <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]




--- Comment #20 from Gertjan Halkes <[email protected]>  2011-11-15 09:34:38 
---
(In reply to comment #15)
> > By the way, does anyone know a clever way of compile time endianness check?
> 
> Don't you just set up an int and then cast a pointer to it as char * and 
> then look at the bytes?
> 
I've found that using pointer casting can cause some ugly compiler warnings
(mind you, I was dealing with doubles at the time). A cleaner way is using a
union:

static const union { int i; char c; } order = { 1 }; /* initialisation assigns
first union member */

You can then simply check:

if (order.c == 1) {
   /* little endian */
} else {
   /* big endian */
}

Both gcc and llvm/clang recognize this correctly and optimize out the unused
case.


-- 
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email

-- 
## List details at https://lists.exim.org/mailman/listinfo/pcre-dev 

Reply via email to