This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: macros to detect endiannes?
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: Kimmo Fredriksson <kfredrik at cs dot joensuu dot fi>, gcc-help at gcc dot gnu dot org
- Date: Fri, 29 Aug 2003 13:34:48 -0500
- Subject: Re: macros to detect endiannes?
- References: <" <8184363.1053619149459.JavaMail.nobody"@wamui02.slb.atl.earthlink.net><8184363.1053619149459.JavaMail.nobody@wamui02.slb.atl.earthlink.net>
Hi Kimmo,
GCC is a very good optimizing compiler. A very, very good optimizing compiler.
Before you invest in making endian-aware subroutines, I strongly urge you to consider writing endian-agnostic routines.
And if code profiling IN THE OPTIMIZED CODE bears out that those routines need to be & can be made more efficient by being crafted as endian-aware routines, then-and-only-then take the next step by writing non-portable endian-aware code.
Even if the portability is subsumed by macro-triggers of endian-ness to preprocess-in the correct endian-aware code, that code is still less-than-portable.
Also the big-endian and little-endian code needs to be maintained in tandem. That can be a source of problems, via code rot.
KISS is applicable in situations like these. Tricky is not necessarily better. Nor necessarily more efficient.
Sincerely,
--Eljay
More insights at <http://mindprod.com/unmain.html>.