[Python-Dev] Private header files (Was: Renaming Include/object.h)

Barry Warsaw barry at python.org
Thu Jan 4 20:49:58 CET 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Jan 4, 2007, at 2:36 PM, Ronald Oussoren wrote:

> On 4 Jan, 2007, at 17:56, Fred L. Drake, Jr. wrote:
>
>> On Thursday 04 January 2007 11:33, Martin v. Löwis wrote:
>>> For the python subdirectory, there is the issue that the framework
>>> includes in OSX magically look for python.framework when  
>>> searching for
>>> python/foo.h, which they find, so that may get us the wrong version.
>>> Somebody would have to study the details here, first.
>>
>> If everything public gets included from Python.h, perhaps python/ 
>> object.h and
>> friends could become pythonX.Y/object.h; I'm not sure this will  
>> solve the Mac
>> OS framework magic issue, though, not being a Mac OS developer.
>
> That would solve the problem, however I don't think there is one.  
> An experiment seems to indicate that the include path is prefered  
> over the magic inclusion of framework headers (see the trace  
> below). I haven't checked yet if the behaviour shown below is  
> intentional, but I'd be surprised if it isn't.
>
> $ mkdir include
> $ mkdir include/Python
> $ cat > include/Python/object.h <<EOF
> #error "my header included"
> EOF
> $ cat > demo.c <<-EOF
> #include <Python/object.h>
> EOF
> $
> $ cc -c demo.c
> In file included from demo.c:1:
> /System/Library/Frameworks/Python.framework/Headers/object.h:227:  
> error: parse error before ‘FILE’
> /System/Library/Frameworks/Python.framework/Headers/object.h:353:  
> error: parse error before ‘PyType_IsSubtype’
> ... more errors removed, this clearly includes a header from the  
> python framework
> $
> $ cc -I include -c t.c
> In file included from demo.c:1:
> include/Python/object.h:1:2: error: #error "my error"
>
> Therefore moving all headers into a directory named Python would  
> cause no problems users that use the normal way of linking with  
> python and would even allow users to use the python framework as a  
> normal framework.

I think that's basically correct: framework includes are searched  
after normal includes.  You might be able to confuse things if you  
used -F/-framework options, because I believe those are interleaved  
with -I paths, but then if you add -F presumably you should know what  
you're doing.

Thanks for testing this.
- -Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iQCVAwUBRZ1abHEjvBPtnXfVAQJQtAP/XgGgI2z7xUGJlxBGfZiggIEtxRYzJObn
TVl/2r7tJ58QCwTzc+eI/m18gcfi85q+hmS1hPc9tjq0ICiqZGjSI9hpSsq0Uqva
WXKFscmvnNyZLrhemy8AjHSbA7dKKBGKBmqycjEt26am4LetoCD/HCt44+AaoI3d
SIzFFiSKw/4=
=4FpY
-----END PGP SIGNATURE-----


More information about the Python-Dev mailing list