Manolo on Thu, 26 Jul 2012 17:03:26 +0200

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

Global persistent variables (compiled code)

I need to fix some global variables and so I initialize their values
with init_library()-like function.


static GEN myvar1;
static GEN myvar2;
/*End of global vars*/

init_mylib(void)	  /* void */

  static long init_done = 0;
  if (init_done) return;

*** staff related to my global vars ***

 init_done = 1;

Then, I import the library on a pari session (via "install" "run"-file
and so on...). If I try to run a function:

? mylib_myfunction()

it returns error, because I didn't initialize the global vars. So I must run:

? init_mylib(); mylib_myfunction()

And it works. That's ok up to now.

But if try again

? mylib_myfunction()

or even try again the same step with initialization,

? init_mylib(); mylib_myfunction()

I receive an error, because global vars are not ok!!! I must leave the
session an enter again to get my code working.

I guess that "normal" static variables like "init_done" are kept, but
pari-variables don't.

How can I solve this?


Manuel Pancorbo Castro