American Citizen on Tue, 16 Apr 2024 21:20:16 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

simple question on why indice variables are not counted as variables for gp2c-run command


I have a simple question here,

Let test_fun.gp be a simple script file (basically doing nothing)

{test_fun(n)=
local(i,j,x);
for(i=1,n-1,
 for(j=i+1,n,
   x=x;
 );
);
return(0);
}

Then when executing the command "gp2c-run test_fun.gp", I get these results

test.gp.c: In function ‘test_fun’:
test.gp.c:20:18: warning: unused variable ‘j’ [-Wunused-variable]
   20 |   GEN i = gen_0, j = gen_0, x = gen_0, p1;
      |                  ^
test.gp.c:20:7: warning: unused variable ‘i’ [-Wunused-variable]
   20 |   GEN i = gen_0, j = gen_0, x = gen_0, p1;
      |       ^
Reading GPRC: /home/owner/.gprc
GPRC Done.

Is the c-compiler purposefully ignoring the i,j as index variables in the loop?

Normally I would declare such variables, and conventional C has the type explicitly named, whether outside the loop or in the loop construct.

Just curious.

Randall