[fpc-pascal] scope of defining $mode

David Pethes imcold at imcold.evilhosting.org
Sat Jun 2 19:43:41 CEST 2007


Hi,

I wanted to ask about $mode global directive scope. According to 
http://www.freepascal.org/docs-html/prog/progse3.html#x73-710001.2,
"Global directives affect the whole of the compilation process". Yet, 
when I have two units like this:

//prog.pas
{$mode delphi}
program prog;
uses uni;

function func: integer;
begin
   result := 1;
end;

begin
   writeln(func);
end.


//uni.pas
unit uni;

interface
function somefunc: integer;

implementation
function somefunc: integer;
begin
   result:=1;
end;
end.

it fails to compile on uni.pas if I don't use the -Sd switch (because of 
using result in default fpc mode). So, does the 'whole of the 
compilation process' apply only to the 'prog.pas' file in this case? 
This confuses me a bit, but it's maybe just me misunderstanding the 
docs. Can anybody explain? And a big Thank You for all the work you put 
in fpc.
Best regards,

David



More information about the fpc-pascal mailing list