Forum > Editor
{$I} & {$INCLUDE} Directives
(1/1)
Lightning:
You say that Delphi doesn't support {$I} directives, i can use them in D7 only they aren't so flexible.
I realy would like to know how they can reduce {$IFDEF} directives.
I bellive the Delphi compiler is able to reduce the size of an executable by linking a single unit in the .exe even if it's present in other units that use it and maybe it links only the parts that are needed, not the hole unit (smart linking).
Please tell me if i'm wrong.
Marc:
:?: :?:
Vincent Snijders:
--- Quote from: "Lightning" ---You say that Delphi doesn't support {$I} directives, i can use them in D7 only they aren't so flexible.
I realy would like to know how they can reduce {$IFDEF} directives.
--- End quote ---
Supose, you have different code for linux, freebsd and win32.
You end up with something like:
--- Code: ---{$IFDEF win32}
// win32 code
os := 'win32';
{$ENDIF}
{$IFDEF linux}
os := 'linux';
{$ENDIF}
{$IFDEF freebsd}
os := 'freebsd';
{$ENDIF}
--- End code ---
Alternatively you could put the code for one os in a include file called os.inc and put it in the os-dependent include directory and compile with -Fiwin32 for win32 and -Filinux for linux and -Fifreebsd for freebsd.
example for win32\os.inc
--- Code: ---// win32 code
os := 'win32';
--- End code ---
Anonymous:
What about comon code, wouldn't it have to be rewritten for each platform ?
Won't it be nice to see alll the code an modify it so that parts will be common and see the differences
between platforms easily ?
Vincent Snijders:
Yes, comon code doesn't have to rewritten. A very good example is the fpc RTL, which targets at least 4 processors and at least 6 operation system.
Navigation
[0] Message Index