Hi all,
I'm trying to use the simple GPC modules mechanism, as described in the Doc (7.1.8.1, page 85), and can't figure out how to link the provided example, with module DemoMod3 and program ModDemo3.
I'm using GPC 20011202 on Solaris-8; I tried several methods, for example:
% gpc --automake moddemo3.pas
and always get undefined linking errors:
Setfoo /var/tmp/cc2daawp1.o Getfoo /var/tmp/cc2daawp1.o
I guess the solution is really simple, but can't find it, please help!
Here's the example source code:
module DemoMod3;
type FooType = Integer;
var Foo : FooType;
procedure SetFoo (f : FooType); begin Foo := f; end; { SetFoo }
function GetFoo: Footype; begin GetFoo := Foo; end; { GetFoo }
end.
program ModDemo3 (Output);
type FooType = Integer;
procedure SetFoo (f : FooType); external; function GetFoo: FooType; external;
begin SetFoo (999); Writeln (GetFoo); end.
-- Nicolas
Nicolas Courtel wrote:
I'm trying to use the simple GPC modules mechanism, as described in the Doc (7.1.8.1, page 85), and can't figure out how to link the provided example, with module DemoMod3 and program ModDemo3.
I'm using GPC 20011202 on Solaris-8; I tried several methods, for example:
% gpc --automake moddemo3.pas
and always get undefined linking errors:
Setfoo /var/tmp/cc2daawp1.o Getfoo /var/tmp/cc2daawp1.o
I guess the solution is really simple, but can't find it, please help!
Here's the example source code:
Works for me. Perhaps you need to specify the `asmname's (anyway, this will be required in the future when GPC will support qualified identifiers, so you might as well do it now, and perhaps it will solve your problem):
module DemoMod3;
type FooType = Integer;
var Foo : FooType;
procedure SetFoo (f : FooType); asmname 'setfoo'; procedure SetFoo (f : FooType); begin Foo := f; end; { SetFoo }
function GetFoo: Footype; asmname 'getfoo'; function GetFoo: Footype; begin GetFoo := Foo; end; { GetFoo }
end.
program ModDemo3 (Output);
type FooType = Integer;
procedure SetFoo (f : FooType); asmname 'setfoo'; external; function GetFoo: FooType; asmname 'getfoo'; external;
begin SetFoo (999); Writeln (GetFoo); end.
But I think the regular modules or units (with interface and implementation) parts are easier to use.
(The "simple" above means rather that they're syntactically more primitive, not really that their simpler to use ... ;-)
Frank