Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning '"_POSIX_C_SOURCE" redefined' when include Python.h #41011

Closed
eugenebeast mannequin opened this issue Oct 13, 2004 · 5 comments
Closed

warning '"_POSIX_C_SOURCE" redefined' when include Python.h #41011

eugenebeast mannequin opened this issue Oct 13, 2004 · 5 comments
Labels
extension-modules C modules in the Modules dir

Comments

@eugenebeast
Copy link
Mannequin

eugenebeast mannequin commented Oct 13, 2004

BPO 1045893
Nosy @loewis

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2013-05-10.15:37:26.232>
created_at = <Date 2004-10-13.05:06:02.000>
labels = ['extension-modules', 'invalid']
title = 'warning \'"_POSIX_C_SOURCE" redefined\' when include Python.h'
updated_at = <Date 2013-05-10.15:37:26.232>
user = 'https://bugs.python.org/eugenebeast'

bugs.python.org fields:

activity = <Date 2013-05-10.15:37:26.232>
actor = 'Jonathan.Wakely'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Extension Modules']
creation = <Date 2004-10-13.05:06:02.000>
creator = 'eugene_beast'
dependencies = []
files = []
hgrepos = []
issue_num = 1045893
keywords = []
message_count = 5.0
messages = ['22666', '22667', '22668', '22669', '188842']
nosy_count = 3.0
nosy_names = ['loewis', 'eugene_beast', 'Jonathan.Wakely']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1045893'
versions = ['Python 2.3']

@eugenebeast
Copy link
Mannequin Author

eugenebeast mannequin commented Oct 13, 2004

"""
In file included from /usr/include/python2.3/Python.h:8,
from script.h:21,
from server.cpp:23:
/usr/include/python2.3/pyconfig.h:847:1: warning:
"_POSIX_C_SOURCE" redefined
In file included from
/usr/lib/gcc/i386-redhat-linux/3.4.0/../../../../include/c++/3.4.0/i386-redhat-linux/bits/os_defines.h:39,
from
/usr/lib/gcc/i386-redhat-linux/3.4.0/../../../../include/c++/3.4.0/i386-redhat-linux/bits/c++config.h:35,
from
/usr/lib/gcc/i386-redhat-linux/3.4.0/../../../../include/c++/3.4.0/iostream:44,
from server.cpp:18:
/usr/include/features.h:131:1: warning: this is the
location of the previous definition
""'

The above message is shown whenever program (extending
or embedding python with C/C++) using Python.h was
compilled.

OS: Fedora Core 2
compiller: GCC 3.4.0
libc: glibc-2.3
Python: 2.3.3

@eugenebeast eugenebeast mannequin closed this as completed Oct 13, 2004
@eugenebeast eugenebeast mannequin added invalid extension-modules C modules in the Modules dir labels Oct 13, 2004
@eugenebeast eugenebeast mannequin closed this as completed Oct 13, 2004
@eugenebeast eugenebeast mannequin added invalid extension-modules C modules in the Modules dir labels Oct 13, 2004
@loewis
Copy link
Mannequin

loewis mannequin commented Oct 19, 2004

Logged In: YES
user_id=21627

This is a bug in your program. See

http://docs.python.org/api/includes.html

@eugenebeast
Copy link
Mannequin Author

eugenebeast mannequin commented Oct 20, 2004

Logged In: YES
user_id=126917

But why not made it more compliant in Python.h :

#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE
#endif

???

@loewis
Copy link
Mannequin

loewis mannequin commented Oct 20, 2004

Logged In: YES
user_id=21627

Python itself and Python extensions must be compiled with
precisely the same settings, so taking some other setting of
_POSIX_C_SOURCE may cause binary incompatibility.

If you include Python.h first, as you should,
_POSIX_C_SOURCE will not be defined, so the #ifndef should
not have any effect except in broken extension modules.

@JonathanWakely
Copy link
Mannequin

JonathanWakely mannequin commented May 10, 2013

Insisting on including Python.h first is just broken.

GNU libc's /usr/include/features.h will override it anyway when _GNU_SOURCE is defined:

# undef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 200809L
# undef _XOPEN_SOURCE
# define _XOPEN_SOURCE 700

So if you define _GNU_SOURCE ( which happens automatically when using G++) the annoying defines in pyconfig.h are overridden anyway, so why not just only define them if not already defined?

Either you include Python.h first and its settings get ignored by glibc, or you don't include it first and you get annoying warnings.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir
Projects
None yet
Development

No branches or pull requests

0 participants