<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
OK, making progress: I can get a python program to use my function
defined in pyrex.&nbsp; 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:<br>
<br>
In file included from tempSolveSAC.c:2:<br>
SolveSAC_Wrap.h:6: error: parse error before '(' tokenIn file included
from tempSolveSAC.c:2:<br>
SolveSAC_Wrap.h:6: error: parse error before '(' token<br>
<br>
SolveSAC_Wrap.h:7: warning: data definition has no type or storage class<br>
SolveSAC_Wrap.h:7: warning: data definition has no type or storage class<br>
lipo: can't figure out the architecture type of: /var/tmp//ccQI1vZt.out<br>
<br>
The build details:<br>
<br>
<b>My pyx:<br>
</b><br>
# SolveSAC_Wrap.pyx<br>
<br>
import BMMain as BMM<br>
<br>
test_vals = BMM.BMGlobalInputsWrapper()<br>
test_vals.getAllInputs("/Users/dg/Documents/NOAA/Projects/BaroModes/software/BMSettingsFileWH2Obndries.asc")<br>
<br>
def GetNumVertices():<br>
&nbsp;&nbsp;&nbsp; return _GetNumVertices()<br>
<br>
cdef public long _GetNumVertices():<br>
&nbsp;&nbsp;&nbsp; if test_vals.nodes:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return test_vals.d.getNrows()<br>
<br>
<b>The setup.py (thanks Lenard!):<br>
</b><br>
from distutils.core import setup<br>
from distutils.extension import Extension<br>
from Pyrex.Distutils import build_ext<br>
<br>
setup(<br>
&nbsp; name = 'SolveSAC_Wrap',<br>
&nbsp; ext_modules=[<br>
&nbsp;&nbsp;&nbsp; Extension("SolveSAC_Wrap",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ["SolveSAC_Wrap.pyx"]),<br>
&nbsp;&nbsp;&nbsp; ],<br>
&nbsp; cmdclass = {'build_ext': build_ext}<br>
)<br>
<br>
<b>The python setup.py build_ext --inplace results:<br>
</b><br>
running build_ext<br>
building 'SolveSAC_Wrap' extension<br>
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<br>
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<br>
<br>
<b>The header it produces (SolveSAC_Wrap.h):<br>
</b><br>
#ifdef __cplusplus<br>
#define __PYX_EXTERN_C extern "C"<br>
#else<br>
#define __PYX_EXTERN_C extern<br>
#endif<br>
__PYX_EXTERN_C DL_IMPORT(long) (_GetNumVertices(void));<br>
PyMODINIT_FUNC initSolveSAC_Wrap(void);<br>
<br>
<b>The c file in which I include it (tempSolveSAC.c):<br>
</b><br>
#include "SolveSAC_Wrap.h"<br>
<br>
long SolveSAC( )<br>
{<br>
&nbsp;&nbsp; &nbsp;return _GetNumVertices();<br>
}<br>
<br>
<b>My attempt to compile tempSolveSAC.c:<br>
</b><br>
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 <br>
(I also just tried gcc tempSolveSAC.c, with the same results)<br>
&nbsp;<br>
<b>And, again, the result:<br>
</b>&nbsp;<br>
In file included from tempSolveSAC.c:1:<br>
SolveSAC_Wrap.h:6: error: parse error before '(' token<br>
SolveSAC_Wrap.h:7: warning: data definition has no type or storage class<br>
In file included from tempSolveSAC.c:1:<br>
SolveSAC_Wrap.h:6: error: parse error before '(' token<br>
SolveSAC_Wrap.h:7: warning: data definition has no type or storage class<br>
lipo: can't figure out the architecture type of: /var/tmp//ccmMO4oM.out<br>
<br>
Thanks for your help.<br>
<br>
DG
</body>
</html>