Re: Robust detection of endianness at compile time.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Lee Rhodes wrote:

> Since these header files
> define the correct answer for my platform I presume that they are
> automatically generated during installation of the compiler as neither
> header file appears as such in the build directory for a newly compiled GCC
> (for c/c++). 

Standard C header files in /usr/include such as endian.h are part of the
libc.  They are not part of the compiler.  So no, they are not generated
during installation of gcc, they are part of libc and installed when
libc was installed.

> The recommended method to list all the predefined macros:
>   echo "" | gcc -E -dM -x c - | sort
> doesn't list ANY of the above endian macros!

They are just regular ordinary #defines in a header file, which by
definition means they are not built-in.  The above shows only the
defines that are built-in to the compiler/preprocessor, i.e. the state
of the preprocessor namespace before any header file or user code is
parsed.

> Questions:
> 1.  Since the compiler clearly HAS to know endianess why isn't there a
> simple, robust way to test for it on all platforms without depending on a
> header?

As I said already, autoconf.

> 4.  Why are these very basic platform constants NOT included in the -dM
> output list?

Because they are not built-in to the compiler (at least, not on the
platform you are using.)

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux