Recent

Author Topic: {$I} & {$INCLUDE} Directives  (Read 8678 times)

Lightning

  • Sr. Member
  • ****
  • Posts: 422
{$I} & {$INCLUDE} Directives
« on: June 17, 2004, 12:01:38 pm »
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.
The future must be... Fast and OpenSource so...
Think Open and Lightning Fast!

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
{$I} & {$INCLUDE} Directives
« Reply #1 on: June 17, 2004, 03:14:02 pm »
:?:  :?:
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: {$I} & {$INCLUDE} Directives
« Reply #2 on: June 17, 2004, 09:20:14 pm »
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.


Supose, you have different code for linux, freebsd and win32.
You end up with something like:
Code: [Select]
{$IFDEF win32}
// win32 code
os := 'win32';
{$ENDIF}
{$IFDEF linux}
os := 'linux';
{$ENDIF}
{$IFDEF freebsd}
os := 'freebsd';
{$ENDIF}


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: [Select]
// win32 code
os := 'win32';

Anonymous

  • Guest
{$I} & {$INCLUDE} Directives
« Reply #3 on: June 18, 2004, 12:18:23 pm »
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

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
{$I} & {$INCLUDE} Directives
« Reply #4 on: June 18, 2004, 01:56:51 pm »
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.

 

TinyPortal © 2005-2018