From: Assar Westerlund <[EMAIL PROTECTED]>
   Date: 30 Mar 2000 11:13:59 +0200

   Bob Friesenhahn <[EMAIL PROTECTED]> writes:
   > What about defines like WORDS_BIGENDIAN?  These certainly must appear
   > in a configuration header file.  It seems that the only protection is
   > to surround them with #ifndefs.  Even then, other packages may have
   > conflicting usage.

   I would say that as a library writer I should consider WORDS_BIGENDIAN
   to be in the application name space and nothing I should define.  And
   I would tend to write the public header files such that endian-ness is
   not relevant there.  Or I would need to make that into
   <LIBRARY>_WORDS_BIGENDIAN.

   Why must WORDS_BIGENDIAN appear in a configuration header file?  Sure,
   it will appear in the config.h that configure generates for you when
   building your library but you don't need to install it and you don't
   need to offer it as a header for applications, do you?

The BFD library is an example of code which needs to expose something
like that in the installed bfd.h header file.  It doesn't care about
big vs. little endian, but it cares whether there is a 64 bit integer
data type.

In the case of BFD, we make bfd.h be a generated file to which we
apply autoconf substitution.  We do substitutions based on data
discovered by autoconf.  We then install the generated file.

So bfd-in2.h has code like this:

#define BFD_VERSION  "@VERSION@"
#define BFD_ARCH_SIZE @wordsize@
#define BFD_HOST_64BIT_LONG @BFD_HOST_64BIT_LONG@
#if @BFD_HOST_64_BIT_DEFINED@
#define BFD_HOST_64_BIT @BFD_HOST_64_BIT@
#define BFD_HOST_U_64_BIT @BFD_HOST_U_64_BIT@
#endif

and in configure.in we have this:

AC_OUTPUT(Makefile doc/Makefile bfd-in3.h:bfd-in2.h po/Makefile.in:po/Make-in,

and in Makefile.am we have this:

BFD_H = bfd.h

$(BFD_H): stmp-bfd-h ; @true

stmp-bfd-h: bfd-in3.h
        rm -f bfd-tmp.h
        cp bfd-in3.h bfd-tmp.h
        $(SHELL) $(srcdir)/../move-if-change bfd-tmp.h $(BFD_H)
        rm -f bfd-tmp.h
        touch stmp-bfd-h

This general approach permits recording configuration data in
installed header files without violating the user's namespace.

Ian

Reply via email to