Dear GPC-ers
It's a while since a reported a bug in gpc, but hopefully this one is just me being stupid (again).
I have a main program and a library program which share some global variables and I want to set the variable in the main program and print them out from the library program:
------main.p--------- program main(input,output);
#include "main.h"
begin global_int:=100; global_str:='Goodbye World'; print_globals; end. --------------------
------lib.p----------- module lib(input,output);
#include "main.h"
var global_int:integer; global_str:string(40);
procedure print_globals; begin writeln('global_int=',global_int); writeln('global_str=',global_str); end;
end. -------------------
------main.h-------- var global_int: external integer; global_str: external string(40);
procedure print_globals; external; -------------------
Fairly straightforward, but I get: ida globals/ % gpc -o main main.p lib.p ida globals/ % main global_int=100 global_str=
Not time to say goodbye yet, it seems. If I move the declarations of the global variable from lib.p to main.p I get: ida globals/ % main global_int=100 global_str=Goodbye World
Success, but why ??
Many thanks for a great compiler
Ian
-- Ian Thurlbeck http://www.stams.strath.ac.uk/ Statistics and Modelling Science, University of Strathclyde Livingstone Tower, 26 Richmond Street, Glasgow, UK, G1 1XH Tel: +44 (0)141 548 3667 Fax: +44 (0)141 552 2079