Angelo Fumagalli wrote:
The file vriable and the procedure invocation are declared in other units, as:
unit grfeveis; interface const ..... var tmpf : text; tmpf2: text; sym: text; ..... end.
<Incomplete source skipped>
The problem is related to the fact that file variable tmpf isn't initialized automatically, I set a beakpoint at the beginning of the program (main_pre) and I saw that some file variables (inp, ou) declared in unother pascal unit (prenv) were properly initialized, but which (tmpf, tmpf2, sym) declared into the grfeveis unit are not initialized. In fact the gdb report is:
(gdb) break main_pre Breakpoint 1 at 0x804b0a7: file grfdpmai.p, line 44. (gdb) run Starting program: /dktlvqpe1/grfdev/ags/grfpkglnxv12/grfc.exe
Breakpoint 1, main_pre (d_verb='GRF ') at grfdpmai.p:44 44 if not(prg_host in [1,3]) then cli_setraw; (gdb) where #0 main_pre (d_verb='GRF ') at grfdpmai.p:44 #1 0x0804a06c in main program () at grfidt.p:8 #2 0x0804a0e1 in main (argc=1, argv=0xbfffb4d4, envp=0xbfffb4dc) at <implicit code>:14 (gdb) print _p__M5_Prenv_S7_Inp $1 = {_p_File_ = 0x9f83080} (gdb) print _p__M5_Prenv_S9_Ou $2 = {_p_File_ = 0x9f7f000} (gdb) print _p__M8_Grfeveis_S2_Tmpf2 $3 = {_p_File_ = 0x0} (gdb) print _p__M8_Grfeveis_S3_Tmpf $4 = {_p_File_ = 0x0} (gdb) print _p__M8_Grfeveis_S4_Sym $6 = {_p_File_ = 0x0} (gdb) __________________________________________
The question is: Why such file variables aren't initialized automatically at the program start? I need to call some internal gpc function to force the proper initialization?
Thank you very much in advance for your help.
The variable should be initialized automatically. The rules are: 1) You have to give explict import or uses clause. It does not matter if import is direct or indirect, but if you want to use something from `grfeveis' then there must be a dependency chain from main program to `grfeveis'. 2) Variables in a single module are initialized sequentially. 3) You should not depend on the order in which modules are initialized. It is not arbitrary, but may change in the future.
Typical reason for uninitialized variables are missing dependencies (uses clauses). Sources that you posted are incomplete, so I can not tell more.