next up previous
Next: Using compiled functions in Up: A gp2c tutorial Previous: How can I compile


Using gp2c to find errors in GP scripts

The gp2c compiler can also be used to find errors in GP programs. For that we should use the -W option like in

./gp2c -W pari/examples/squfof.gp > squfof.gp.c

Warning:pari/examples/squfof.gp:7:variable undeclared
p
Warning:pari/examples/squfof.gp:11:variable undeclared
dd
Warning:pari/examples/squfof.gp:11:variable undeclared
d
Warning:pari/examples/squfof.gp:11:variable undeclared
b
...
Warning:pari/examples/squfof.gp:45:variable undeclared
b1

This lists variables that are used but not declared. It is important to declare all your variables with local(), or with global(). For gp2c, undeclared variables are taken to be ``formal variables'' for polynomials. For example if you write a function to build a second degree polynomial like pol(a,b,c)=a*x^2+b*x+c you must not declare 'x' here, since it stands for the formal variable x.



Bill Allombert 2006-01-28