A call from a C function to another raises an error.
import PyInline
pyin = PyInline.build(code = """
#include <stdio.h>
double f(double x){return x;}
double g(double x){return f(x);}
""", language = "C")
print pyin.g(0.1)
gives
Traceback (most recent call last):
File "testpyin.py", line 18, in ?
""", language = "C")
File "PyInline\__init__.py",
line 38, in build
return b.build()
File "PyInline\C.py", line 40
, in build
self._parse()
File "PyInline\C.py", line 92
, in _parse
d['params'] = self._parseParams(d['rawparams'])
File "PyInline\C.py", line 11
0, in _parseParams
return [self._parseParam(p) for p in rawparams]
File "PyInline\C.py", line 11
8, in _parseParam
raise BuildError("Error parsing parameter %s" % p)
PyInline.BuildError: Error parsing parameter x
Logged In: NO
A call to C standard functions causes the same error:
import PyInline
pyin = PyInline.build(code = """
#include <stdlib.h>
double f(double x)
{
double y;
y = x * atof("1.1"); /* error */
/* y = x * atof("1.1") + 0.0; */ /* works */
/* y = atof("1.1") * x; */ /* works */
/* y = atof("1.1"); */ /* works */
/* y = 0.0 + atof("1.1"); */ /* works */
}
""", language = "C")
print pyin.f(0.1)
It seems that c_function_def in c_util.py has a bug of
detecting function defs incorrectly, so the work-around is
to avoid something like "* f(...);" and "return f(...);".
Hope this helps...
Logged In: YES
user_id=1105764
The point is that the return line should be like
return z
the folowwing code work perfectly:
import PyInline
pyin = PyInline.build(code = """
#include <stdio.h>
double f(double x){return 2*x;}
double g(double x){double z = f(x); return z;}
""", language = "C")
print pyin.g(0.1)