Dear GPC, I need to do the following thing: in a main program I write on a file but the "text" variable is declared in another unit.
The program is the following:
program demofile; var test_external_value: integer; external; asmname 'external_value'; var f: text; external; asmname 'f_test_external'; begin writeln('value of test_external_value=', test_external_value); writeln('Create the file FILEDEMO'); {$I-} Assign(f, 'FILEDEMO'); ReWrite(f); {$I+} writeln(f, 'file written by program demofile'); close(f); end.
The unit is the following:
unit demofileunit; interface implementation var test_value: integer = 7; asmname 'external_value'; var f_test: text; asmname 'f_test_external'; end.
Then I compile: gpc -c demofileunit.pas gpc -o demofile demofile.pas demofileunit.o running demofile: value of test_external_value=7 Create the file FILEDEMO demofile: `Unbind' applied to non-bindable TFDD file `(null)' (error #404 at 8049938)
this is the errore received and FILEDEMO is not created.
If I replace in demofile.pas the line: var f: text; external; asmname 'f_test_external'; in the line var f: text; so that f is not external,
compiling and running again demofile: value of test_external_value=7 Create the file FILEDEMO
and the content of FILEDEMO is: file written by program demofile
Then, all is ok.
I installed GPC 2.95.2 with Linux RedHat 7.0 (then gcc is 2.96, but I don't think it is important...)
It seems that it is not possible to link "text" variable externally as I do with other types...Is it a bug? Thanks
Fabio Casamatta
Fabio Casamatta wrote:
Dear GPC, I need to do the following thing: in a main program I write on a file but the "text" variable is declared in another unit.
[...]
Since Fabio had sent the request to me personally before, I've sent him a reply -- just at the same time he posted this to the list.
If anyone else is interested in my answer, let me know.
Frank