tags:

views:

38

answers:

1

I am working on a C library that has SWIG bindings to Python. In my autotools configuration, I check for the gettimeofday function. I have discovered that I can't compile the Python portion of my project because it conflicts with a file pyconfig.h, which also defines HAVE_GETTIMEOFDAY.

This seems like a very general problem, I was surprised to see Python's config.h conflicting with my own. In my project I keep config.h private---i.e., not installed with make install. My impression is that this is correct. I found at least one blog post where this opinion is shared.

Is it a bug that Python conflicts with my config.h?

Edit: I solved it by adding

AC_DEFINE(Py_PYCONFIG_H,[],[Defined here to avoid conflicts with pyconfig.h])

to my configure.ac. Question still stands, should config.h be public in your project, or kept private, only available to implementation files during build?

+3  A: 

It should not be made public to avoid problems like the one you're having. See the Gentoo autotools best-practices document, specifically, the paragraph that starts with The config.h header file should be considered to be an internal header file.

In your case, I would do exactly the same thing that you did: add a #define that prevents processing that file.

Gonzalo
Thanks, good to get some confirmation. Maybe I'll file it as a Python bug.
Steve