[Pyrex] [Mac Inter Core Duo OS 10.4.9 ] compiler complains about pyrex created .h
Lenard Lindstrom
len-l at telus.net
Sat Jun 9 02:30:36 UTC 2007
David Goldsmith wrote:
> I googled Pyrex: "parse error before '(' token" and hit an archived
> SciPy post; the message following the relevant post - it was unclear
> whether it was next in thread, next in time, or both - suggested that
> the problem might be an out-dated Numeric. Have you all updated to
> numpy, and if not, if I don't have Numeric, only numpy, could that be
> the (or will that be a) problem?
>
> DG
>
>
This is nothing to do with Numeric. See below.
> David Goldsmith wrote:
>
>> OK, making progress: I can get a python program to use my function
>> defined in pyrex. However, when I try to compile a c file in which
>> I've included the header pyrex produced (because I made a function
>> public so that I could call the function in a c program), the compiler
>> complains:
>>
>> In file included from tempSolveSAC.c:2:
>> SolveSAC_Wrap.h:6: error: parse error before '(' tokenIn file included
>> from tempSolveSAC.c:2:
>> SolveSAC_Wrap.h:6: error: parse error before '(' token
>>
>> SolveSAC_Wrap.h:7: warning: data definition has no type or storage class
>> SolveSAC_Wrap.h:7: warning: data definition has no type or storage class
>> lipo: can't figure out the architecture type of: /var/tmp//ccQI1vZt.out
>>
>>
[snip]
>> *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 .
>> *The c file in which I include it (tempSolveSAC.c):
>> *
>> #include "SolveSAC_Wrap.h"
>>
>> long SolveSAC( )
>> {
>> return _GetNumVertices();
>> }
>>
>>
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.
>> *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.
--
Lenard Lindstrom
<len-l at telus.net>
More information about the Pyrex
mailing list