[Pyrex] [Mac Inter Core Duo OS 10.4.9 ] compiler complains about pyrex created .h

David Goldsmith David.L.Goldsmith at noaa.gov
Sat Jun 9 03:09:32 UTC 2007


Lenard Lindstrom wrote:
>>> *The header it produces (SolveSAC_Wrap.h):
>>> *
>>> #ifdef __cplusplus
>>> #define __PYX_EXTERN_C extern "C"
>>> #else
>>> #define __PYX_EXTERN_C extern
>>> #endif
>>> __PYX_EXTERN_C DL_IMPORT(long) (_GetNumVertices(void));
>>> PyMODINIT_FUNC initSolveSAC_Wrap(void);
>>>
>>>     
>>>       
> The Pyrex generated header is using definitions found in Python.h . That 
> must be included before SolveSAC_Wrap.h .
>   
Ah-ha!
> I don't know how you intend to use SolveSAC(). You can't just call a 
> function that uses Python from a C program. This is embedding. The 
> Python interpreter must be initialized and the relevant Python modules 
> imported first. See "Extending and Embedding" in the Python Documentation.
>   
SolveSAC is a piece of some legacy C code that we want to preserve from 
code we're updating for OSX, but wrap w/ Python so that it will be 
easier for it to be cross-platform, as well as easier to maintain in the 
future.  Ultimately we will be writing file IO, GUI, etc., in Python and 
preserving just the C numerics from the old code, so the paradigm we're 
working with *is* that the C will be used in a quasi-library like 
fashion with a mostly Python/Pyrex implementation.  But, since I'm just 
getting started w/ Pyrex, I'm taking baby-steps; also, we haven't 
exactly settled on Pyrex yet - SWIG and ctypes are still under 
consideration - but I've tried SWIG, someone else is trying ctypes, so 
now I'm trying SWIG.  Of course to properly evaluate it, I need to get 
it top work the way we need it to.

DG
>>> *My attempt to compile tempSolveSAC.c:
>>> *
>>> gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk 
>>> -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd 
>>> -fno-common -dynamic -DNDEBUG -g -O3 
>>> -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 
>>> -c tempSolveSAC.c
>>> (I also just tried gcc tempSolveSAC.c, with the same results)
>>>  
>>> *And, again, the result:
>>> * 
>>> In file included from tempSolveSAC.c:1:
>>> SolveSAC_Wrap.h:6: error: parse error before '(' token
>>> SolveSAC_Wrap.h:7: warning: data definition has no type or storage class
>>> In file included from tempSolveSAC.c:1:
>>> SolveSAC_Wrap.h:6: error: parse error before '(' token
>>> SolveSAC_Wrap.h:7: warning: data definition has no type or storage class
>>> lipo: can't figure out the architecture type of: /var/tmp//ccmMO4oM.out
>>>
>>>     
>>>       
>
> Definitions are missing.
>
>
>   




More information about the Pyrex mailing list