python: silence macro redefinition warnings

Python defines _XOPEN_SOURCE and _POSIX_C_SOURCE unconditionally.  On Linux,
this is problematic as glibc's features.h defines these values if _GNU_SOURCE is
defined to the value that is currently implemented.  Python defines it to the
versions that it requires, which may be different.  Undefine the macros on Linux
(technically, this should be safe to do globally) before including the python
headers.

llvm-svn: 208520
This commit is contained in:
Saleem Abdulrasool 2014-05-12 06:44:01 +00:00
parent fba09d47e9
commit f69b64d6d2
1 changed files with 9 additions and 0 deletions

View File

@ -18,6 +18,15 @@
#else
#if defined(__linux__)
// features.h will define _POSIX_C_SOURCE if _GNU_SOURCE is defined. This value
// may be different from the value that Python defines it to be which results
// in a warning. Undefine _POSIX_C_SOURCE before including Python.h The same
// holds for _XOPEN_SOURCE.
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#endif
#include <Python.h>
#endif // LLDB_DISABLE_PYTHON