Re: [Python-Dev] A bug in pyconfig.h under Linux?

2005-06-14 Thread Fernando Perez
"Martin v. Löwis" wrote:

> Fernando Perez wrote:
>> sorry for posting to this list, but I'm not even 100% sure this is a bug. 
>> If it is, I'll gladly post it to SF if you folks want it there.
> 
> This is not a bug. Most likely, sc_weave.cpp fails to meet the
> requirement documented in
> 
> http://docs.python.org/api/includes.html
> 
> "Warning:  Since Python may define some pre-processor definitions which
> affect the standard headers on some systems, you must include Python.h
> before any standard headers are included. "

Many thanks to Martin and Jeff Epler for the feedback, and sorry for the noise,
the bug was in weave and not in pyconfig.h. 

I was able to fix scipy's weave to respect this constraint, which it didn't in
the case of blitz-enhanced array handling code.

Regards,

f

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] A bug in pyconfig.h under Linux?

2005-06-14 Thread Martin v. Löwis
Fernando Perez wrote:
> sorry for posting to this list, but I'm not even 100% sure this is a bug.  If 
> it
> is, I'll gladly post it to SF if you folks want it there.

This is not a bug. Most likely, sc_weave.cpp fails to meet the
requirement documented in

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

"Warning:  Since Python may define some pre-processor definitions which
affect the standard headers on some systems, you must include Python.h
before any standard headers are included. "

If you follow this recommendation, this kind of error should not occur.

Regards,
Martin
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] A bug in pyconfig.h under Linux?

2005-06-14 Thread Fernando Perez
Hi all,

sorry for posting to this list, but I'm not even 100% sure this is a bug.  If it
is, I'll gladly post it to SF if you folks want it there.

I use scipy a lot, and the weave.inline component in there allows dynamic
inclusion of C/C++ code in Python sources.  In particular, it supports Blitz++
array expressions for access to Numeric arrays.  However, whenever I use
blitz-based code, I get these annoying warnings:


In file included from /usr/include/python2.3/Python.h:8,
 from sc_weave.cpp:5:
/usr/include/python2.3/pyconfig.h:850:1: warning: "_POSIX_C_SOURCE" redefined
In file included
from 
/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../../include/c++/3.4.3/i386-redhat-linux/bits/os_defines.h:39,

from 
/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../../include/c++/3.4.3/i386-redhat-linux/bits/c++config.h:35,

from 
/usr/lib/gcc/i386-redhat-linux/3.4.3/../../../../include/c++/3.4.3/string:45,

from /usr/lib/python2.3/site-packages/weave/blitz-20001213/blitz/blitz.h:153,

from 
/usr/lib/python2.3/site-packages/weave/blitz-20001213/blitz/array-impl.h:154,

from /usr/lib/python2.3/site-packages/weave/blitz-20001213/blitz/array.h:94,
 from sc_weave.cpp:4:
/usr/include/features.h:150:1: warning: this is the location of the previous
definition


This is on a Fedora Core 3 box, using glibc-headers.i386 version 2.3.5.

The source of the problem seems to be that in
file /usr/include/python2.3/pyconfig.h, line 850, I have:

/* Define to activate features from IEEE Stds 1003.1-2001 */
#define _POSIX_C_SOURCE 200112L

But the system headers, in /usr/include/features.h, line 150 give:

# define _POSIX_C_SOURCE199506L

Hence the double-define.  Now, I noticed that the system headers all use the
following approach to defining these constants:

# undef  _POSIX_SOURCE
# define _POSIX_SOURCE  1
# undef  _POSIX_C_SOURCE
# define _POSIX_C_SOURCE199506L

etc.  That is, they undef everything before defining their value.  I applied the
same change manually to pyconfig.h:

/* Define to activate features from IEEE Stds 1003.1-2001 */
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L

and my spurious warnings went away.  But I realize that pyconfig.h is
auto-generated, so the right solution, if this is indeed a bug, has to be
applied somewhere else, at the code generation source.  I am unfortunately not
familiar enough with Python's build system and the autoconf toolset to do that. 
Furthermore, I am not even 100% sure this is really a bug, though the spurious
warning is very annoying.

If this is indeed a bug, do you folks want it reported on SF as such?  In that
case, is this explanation enough/correct?  Any advice would be much
appreciated.

Regards,

Fernando.

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com