compile error : in step for using simple sprintf function

Hi~

I’m struggling with compiling ngspice code using pgcc.
For previous problem ‘static linking’, I’ve finally solved with your help :)
The next thing is as follows.

In some routine, there are simple function like that,

long
np_round(double x)
/* using <math.h>, it would be simpler: floor(x+0.5), see below */
{
double u;
long z;
int n;

SPICE_DSTRING s;

spice_dstring_init(&s);
u = 2e9;

if (x > u)
x = u;
else if (x < -u)
x = -u;

n = sprintf(s, “%-12.0f”, x);
s[n] = 0;
sscanf(s, “%ld”, &z);

return z;
}

During compiling above code, some errors are happen with below messages:





/opt/pgi/linux86-64/12.8/bin/pgc …/…/…/…/src/frontend/numparam/mystring.c -opt 2 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -x 59 4 -tp sandybridge -x 120 0x1000 -astype 0 -stdinc /opt/pgi/linux86-64/12.8/include:/usr/local/include:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include:/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include:/usr/include -def unix -def __unix -def unix -def linux -def __linux -def linux -def __NO_MATH_INLINES -def __x86_64 -def x86_64 -def LONG_MAX=9223372036854775807L -def ‘SIZE_TYPE=unsigned long int’ -def ‘PTRDIFF_TYPE=long int’ -def __THROW= -def extension= -def amd_64__amd64 -def __k8 -def k8 -def SSE -def MMX -def SSE2 -def SSE3 -def SSSE3 -predicate ‘#machine(x86_64) #lint(off) #system(posix) #cpu(x86_64)’ -idir . -idir …/…/…/…/src/frontend/numparam -idir …/…/…/src/include -idir …/…/…/…/src/include -def HAVE_CONFIG_H -cmdline ‘+pgcc …/…/…/…/src/frontend/numparam/mystring.c -DHAVE_CONFIG_H -I. -I…/…/…/…/src/frontend/numparam -I…/…/…/src/include -I…/…/…/…/src/include -O2 -v -mp -c’ -x 123 0x80000000 -x 123 4 -x 119 0x20 -def __pgnu_vsn=40407 -alwaysinline /opt/pgi/linux86-64/12.8/lib/libintrinsics.il 4 -x 120 0x200000 -mp -x 69 0x200 -x 69 0x400 -asm /tmp/pgccrcddZL2QQFmD.s
PGC-I-0222-Redundant definition for symbol __THROW (/usr/include/sys/cdefs.h: 63)
PGC-I-0222-Redundant definition for symbol extension (/usr/include/sys/cdefs.h: 339)
PGC-I-0222-Redundant definition for symbol HAVE_SIGSETJMP (…/…/…/src/include/ngspice/config.h: 281)
PGC-I-0222-Redundant definition for symbol HAVE_SIGSETJMP (…/…/…/src/include/ngspice/config.h: 281)
PGC-I-0145-Syntax requires no comma, comma deleted (…/…/…/…/src/include/ngspice/miftypes.h: 78)
PGC-I-0145-Syntax requires no comma, comma deleted (…/…/…/…/src/include/ngspice/miftypes.h: 90)
PGC-I-0145-Syntax requires no comma, comma deleted (…/…/…/…/src/include/ngspice/miftypes.h: 110)
PGC-I-0145-Syntax requires no comma, comma deleted (…/…/…/…/src/include/ngspice/miftypes.h: 122)
PGC-I-0145-Syntax requires no comma, comma deleted (…/…/…/…/src/include/ngspice/miftypes.h: 138)
PGC-I-0145-Syntax requires no comma, comma deleted (…/…/…/…/src/include/ngspice/miftypes.h: 158)
PGC-I-0145-Syntax requires no comma, comma deleted (…/…/…/…/src/include/ngspice/miftypes.h: 172)
PGC-S-0094-Illegal type conversion required (…/…/…/…/src/frontend/numparam/mystring.c: 613)
PGC-S-0054-Subscript operator ([]) applied to non-array (…/…/…/…/src/frontend/numparam/mystring.c: 614)
PGC-S-0094-Illegal type conversion required (…/…/…/…/src/frontend/numparam/mystring.c: 615)

PGC/x86-64 Linux 12.8-1: compilation completed with severe errors
pgcc-Fatal-ccompile completed with exit code 1

Could you please let know what is the problem? TT

Hi TT,

For previous problem ‘static linking’, I’ve finally solved with your help :)

So you were trying to statically link the pthreads library? What you can do is use “-Bstatic_pgi” in which case the PGI runtime will be statically linked but not the system libraries.


What is the definition of “SPICE_DSTRING”? It’s being used like a “char *” but the error indicates that it’s something else.

  • Mat