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

David Goldsmith David.L.Goldsmith at noaa.gov
Fri Jun 8 22:43:09 UTC 2007


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

The build details:

*My pyx:
*
# SolveSAC_Wrap.pyx

import BMMain as BMM

test_vals = BMM.BMGlobalInputsWrapper()
test_vals.getAllInputs("/Users/dg/Documents/NOAA/Projects/BaroModes/software/BMSettingsFileWH2Obndries.asc")

def GetNumVertices():
    return _GetNumVertices()

cdef public long _GetNumVertices():
    if test_vals.nodes:
        return test_vals.d.getNrows()

*The setup.py (thanks Lenard!):
*
from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext

setup(
  name = 'SolveSAC_Wrap',
  ext_modules=[
    Extension("SolveSAC_Wrap",       ["SolveSAC_Wrap.pyx"]),
    ],
  cmdclass = {'build_ext': build_ext}
)

*The python setup.py build_ext --inplace results:
*
running build_ext
building 'SolveSAC_Wrap' extension
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 
SolveSAC_Wrap.c -o build/temp.macosx-10.3-fat-2.5/SolveSAC_Wrap.o
gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g 
-bundle -undefined dynamic_lookup 
build/temp.macosx-10.3-fat-2.5/SolveSAC_Wrap.o -o SolveSAC_Wrap.so

*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 c file in which I include it (tempSolveSAC.c):
*
#include "SolveSAC_Wrap.h"

long SolveSAC( )
{
    return _GetNumVertices();
}

*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

Thanks for your help.

DG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20070608/20040dae/attachment.html 


More information about the Pyrex mailing list