0

In the autoconf manual, it is noted that

AC_INIT (package, version, [bug-report], [tarname], [url])

defines multiple macro names such as AC_PACKAGE_NAME and PACKAGE_NAME.

Running configure also generates a config file with definition like the following:

define HAVE_LIBGMP 1

As I am writing C++ code, I find these macros annoying yet useful. In fact, it happened many times that I needed to link with a library that uses the autotools and thus has these macros in its headers. So the situation is that there is conflict on headers macros such as:

define PACKAGE_NAME "library"

define PACKAGE_NAME "mine"

So, I was wondering if there was a way to tell the autotools to define at least some of these macros inside some kind of structure as follows:

`struct header_information{
static string package_name;
static bug_report;
....
}`

and then initialize it with the right macro names. This solution would keep these informations encapsulated and does not pollute the global namespace ?

Community
  • 1
  • 1
user2414029
  • 71
  • 1
  • 5
  • 1
    The problem is that many package maintainers incorrectly install `config.h` and pollute the global namespace. Any package that installs its `config.h` should have a bug filed against it. – William Pursell Jun 01 '13 at 15:04

1 Answers1

0

It seems to me like you want to abuse a package-private, build-system-ony configuration header file (config.h) that just so happens to define a convenient macro name that you'd like to use. I think the pretty obvious answer is "don't do that", or else you're on your own.

Unless I'm misunderstanding you?

Those defines are there so that the particular library can use them. It's not meant for other things to include. In fact, the majority of the things in config.h are completely useless outside of the particular package.

That doesn't mean that the library that config.h file belongs to couldn't provide what you're looking for, by defining a public struct in a header that uses those variables. Or perhaps a library that uses pkg-config (if you're just looking for package names) can provide some of information for you. But I don't think that autotools would or should provide that information to you.

clemej
  • 2,553
  • 2
  • 19
  • 28