Issue 7573: Position independent include of Python.h (original) (raw)

Created on 2009-12-24 11:26 by instigate_team, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (10)

msg96852 - (view)

Author: (instigate_team)

Date: 2009-12-24 11:26

Hello Python development team!

We encountered problem concerning Python 3.1 usage.

Platform info:

Ubuntu 9.10 32/64bit, glibc v. 2.10.1, gcc v. 4.4.0, Python 3.1.

Problem description:

Below is given the C++ program text causing the warning:

#include #include <Python.h>

int main() { return 0; }

Compilation result is the following:

In file included from /usr/include/python3.1/Python.h:8, from main.cpp:3: /usr/include/python3.1/pyconfig.h:1108:1: warning: "_POSIX_C_SOURCE" redefined In file included from /usr/include/c++/4.4/i486-linux-gnu/bits/os_defines.h:39, from /usr/include/c++/4.4/i486-linux-gnu/bits/c++config.h:243, from /usr/include/c++/4.4/string:40, from main.cpp:2: /usr/include/features.h:158:1: warning: this is the location of the previous definition In file included from /usr/include/python3.1/Python.h:8, from main.cpp:3: /usr/include/python3.1/pyconfig.h:1130:1: warning: "_XOPEN_SOURCE" redefined In file included from /usr/include/c++/4.4/i486-linux-gnu/bits/os_defines.h:39, from /usr/include/c++/4.4/i486-linux-gnu/bits/c++config.h:243, from /usr/include/c++/4.4/string:40, from main.cpp:2: /usr/include/features.h:160:1: warning: this is the location of the previous definition

Analyzing the error:

We find out that the includes sequence influences on the application build. We have no problem in case if Python header is included before "string" file. The problem is concerning the conflict of pyconfig.h and features.h (/usr/include/features.h, which is the part of glibc), which is included in string header file. We have the same result with any header file, which includes features.h file.

File features.h defines _POSIX_C_SOURCE in case of some conditions are true.

In its turn pyconfig.h contains the following code in line 1108

#define _POSIX_C_SOURCE 200112L

And we get redefinition warning. Our projects are working with gcc -Werror flags, so this is the blocking problem.

The same happened with _XOPEN_SOURCE.

Any help from your side will be very much appreciated.

msg96855 - (view)

Author: Martin v. Löwis (loewis) * (Python committer)

Date: 2009-12-24 12:09

If you do reorder the include statements, will then the warning go away?

msg96856 - (view)

Author: (instigate_team)

Date: 2009-12-24 13:48

Yes, We have no warnings after changing the include sequence.

msg99721 - (view)

Author: Stefan Krah (skrah) * (Python committer)

Date: 2010-02-22 11:23

This is documented, so I'd recommend to close this issue.

http://docs.python.org/3.1/c-api/intro.html#include-files

msg100147 - (view)

Author: (instigate_team)

Date: 2010-02-26 11:02

This is a solution in case if an application contains only several files, where I can control the includes consequence. But if application has many files, directories, in this case the hierarchy of the files includes can not be traced.

msg100150 - (view)

Author: Brian Curtin (brian.curtin) * (Python committer)

Date: 2010-02-26 14:26

That solution will work if you have 1 file or 1000 files. The note on the documentation is very clear on what has to happen.

msg100154 - (view)

Author: Stefan Krah (skrah) * (Python committer)

Date: 2010-02-26 15:13

instigate_team, you said earlier that you have no warnings if you change the include sequence according to the documentation. Unless you provide a concrete example where the position dependent include of Python.h makes building impossible (as opposed to being a minor nuisance), I'd say that this is a feature request.

msg100255 - (view)

Author: (instigate_team)

Date: 2010-03-01 12:38

Ok, this can be considered as a future request as Ubuntu 9.10 not so common operating system nowdays.

Please note that the error was noticed only on Ubuntu 9.10, where glibc library version is 2.10.1. Python works OK with GNU C library versions less than 2.10.1.

msg184514 - (view)

Author: Ned Jackson Lovely (n) *

Date: 2013-03-18 20:28

Should this be closed?

msg192653 - (view)

Author: Christian Heimes (christian.heimes) * (Python committer)

Date: 2013-07-08 14:13

Yes, I'm closing it. The issue has been addressed in our documentation.

History

Date

User

Action

Args

2022-04-11 14:56:55

admin

set

github: 51822

2013-07-08 14:13:31

christian.heimes

set

status: open -> closed

nosy: + christian.heimes
messages: +

resolution: fixed

2013-03-18 20:28:55

n

set

nosy: + n
messages: +

2010-03-01 12:38:25

instigate_team

set

messages: +

2010-02-26 15:13:57

skrah

set

type: compile error -> enhancement
title: Python build issue on Ubuntu 9.10 -> Position independent include of Python.h
messages: +
versions: + Python 3.2, - Python 3.1

2010-02-26 14:26:16

brian.curtin

set

nosy: + brian.curtin
messages: +

2010-02-26 11:02:20

instigate_team

set

messages: +

2010-02-22 11:23:30

skrah

set

nosy: + skrah
messages: +

2009-12-24 13:48:21

instigate_team

set

messages: +

2009-12-24 12:09:56

loewis

set

nosy: + loewis
messages: +

2009-12-24 11:26:19

instigate_team

create