Subject: | Cannot include <string.h> to use memset |
Q1 Try the following one line function, this is enough to describe the
problem.
I need tens of Gaussian and Lorentzian functions to add up together to
present one x[i], so I would like to set x[] to all zero first, then do
x[i] += ...
perl -e 'use PDL::Fit::Levmar; use PDL::Fit::Levmar::Func; levmar_func(
FUNC => q(
function
noloop
#include<string.h>
memset( x, 0, n );
// bla, bla, bla...
)
);
exit 1;
'
But I get the error below:
In file included from /usr/include/string.h:635,
from tempcode/func5.c:13:
/usr/include/bits/string2.h: In function ‘func’:
/usr/include/bits/string2.h:972: error: nested function ‘__strcspn_c1’
declared ‘extern’
...
/usr/include/bits/string3.h:51: error: nested function ‘memcpy’ declared
‘extern’
/usr/include/bits/string3.h:49: error: static declaration of ‘memcpy’
follows non-static declaration
/usr/include/bits/string3.h:58: error: nested function ‘memmove’
declared ‘extern’
/usr/include/bits/string3.h:56: error: static declaration of ‘memmove’
follows non-static declaration
/usr/include/bits/string3.h:79: error: nested function ‘memset’ declared
‘extern’
/usr/include/bits/string3.h:78: error: static declaration of ‘memset’
follows non-static declaration
...
tempcode/func5.c: In function ‘sfunc’:
tempcode/func5.c:29: warning: incompatible implicit declaration of
built-in function ‘memset’
...
I am using: Ubuntu 32bit v10.04, gcc v4.4.3, perl v5.14.2, PDL v2.4.10,
and PDL::Fit::Levmar v0.0089.
Thank you for the help.
Q2: When I was compiling the PDL::Fit::Levmar package, the test failed
for a few cases, and thus the total result is fail. I still manually
installed. I am not putting more information here, since this is not my
main question in the post, but I am wondering is this a normal problem
for every one?
Q3: By the way, I am wondering if the C compiler used in Levmar is with
perl or with gcc? Does it automatically use -O3 option or there is no
such option to be chosen at all?