Automatically initialize all global variables/arrays in GCC.

Kevin Hung cykhung@gmail.com
Thu Jul 5 20:20:00 GMT 2007


I am using gcc to compile our C code under Linux. After compiling and
linking, we use SWIG to create python wrapper for the C code so that
we can execute C functions in python.

My question is: When our C program gets loaded into python, is it
possible to have all global variables/arrays in our C code to be
initialized to some magic constants (say all ones)? I think if this is
possible, it would be a linker option under GCC. My gcc version is:

gcc version 3.3.5 (Debian 1:3.3.5-12)

I have looked through the online manual for gcc but could not find
anything that is related to my problem. Actually I am not 100% sure
whether this is done by the compiler or SWIG.

Thanks.



More information about the Gcc-help mailing list