fpc/tests/test/tweaklib2.pp
Jonas Maebe a23630260b + "weakexternal" support for imported procedures and variables.
the syntax is exactly the same as for "external", except for
    the keyword. It is currently only active for Darwin targets.
    It should also work at least for Linux targets, but only with
    the GNU assembler (which is why it is not activated there)
  + test for this functionality

git-svn-id: trunk@12009 -
2008-11-01 18:38:32 +00:00

60 lines
1.1 KiB
ObjectPascal

{ %NEEDLIBRARY }
{$ifdef mswindows}
{$define supported}
{$endif mswindows}
{$ifdef Unix}
{$define supported}
{$endif Unix}
{$ifndef fpc}
{$define supported}
{$endif}
{$ifdef supported}
const
{$ifdef windows}
libname='tweaklib1.dll';
{$else}
libname='tweaklib1';
{$linklib tweaklib1}
{$endif}
var
{$ifndef darwin}
_myvar: cardinal; weakexternal libname name '_MYVAR';
_myvar2: cardinal; weakexternal libname name '_MYVAR2';
{$else darwin}
{ needs to be fixed in the compiler }
_myvar: cardinal; weakexternal libname name 'MYVAR';
_myvar2: cardinal; weakexternal libname name 'MYVAR2';
{$endif darwin}
function _test: cardinal; weakexternal libname name '_TEST';
procedure _test2; weakexternal libname name '_TEST2';
begin
{$ifdef darwin}
if (paramcount=0) then
halt(0);
{$endif}
if not assigned(@_test) then
halt(1);
if assigned(@_test2) then
halt(2);
if _test<>$facef00d then
halt(3);
if not assigned(@_myvar) then
halt(4);
if assigned(@_myvar2) then
halt(5);
if (_myvar<>$12345678) then
halt(6);
end.
{$else supported}
begin
{ no library support }
end.
{$endif supported}