Conflicting PACKAGE_NAME and other macros when using autotools.

Posted by baol on Stack Overflow See other posts from Stack Overflow or by baol
Published on 2010-04-03T16:26:43Z Indexed on 2010/04/03 16:33 UTC
Read the original article Hit count: 546

Filed under:
|
|
|
|

When using autotools (with a config.h file) for both a library and a software built on that library the compiler complains about a redefinition of some macros (PACKAGE_NAME, PACKAGE_TARNAME and so on).

How can I prevent this?

The config.h file is needed in the library to propagate it's setting to the software that use it.

Right now I have a wrapper script library_config.h that includes the original config.h and provides defaults when the user is not using autotools, but even undefining the macros in that package I get the redefinition warning from gcc.

#ifndef LIB_CONFIG_H
#define LIB_CONFIG_H
#ifdef HAVE_CONFIG_H
#  include "config.h"
#  undef PACKAGE
#  undef PACKAGE_BUGREPORT
#  undef PACKAGE_NAME
#  undef PACKAGE_STRING
#  undef PACKAGE_TARNAME
#  undef PACKAGE_VERSION
#  undef VERSION
#else
#  if defined (WIN32)
#    define HAVE_UNORDERED_MAP 1
#    define TR1_MIXED_NAMESPACE 1
#  elif defined (__GXX_EXPERIMENTAL_CXX0X__)
#    define HAVE_UNORDERED_MAP 1
#  else
#    define HAVE_TR1_UNORDERED_MAP 1
#  endif
#endif
#endif

I believe the best option would be to have a library without that macros: How can I avoid the definition of PACKAGE, PACKAGE_NAME and so on in the library when using autotools?

© Stack Overflow or respective owner

Related posts about autotools

Related posts about autoconf