Recent

Author Topic: can defines be made global ?  (Read 2888 times)

440bx

  • Hero Member
  • *****
  • Posts: 3944
can defines be made global ?
« on: August 30, 2018, 12:44:24 pm »
Hello,

when defining a symbol, e.g, {$define somesymbol} the definition remains valid in the unit.

Is it possible to have a {$define somesymbol} that defines "somesymbol"  in all the units used by the program without having to re-{$define somesymbol} in every unit ?

Thank you.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: can defines be made global ?
« Reply #1 on: August 30, 2018, 12:45:28 pm »
only if you use a defines.inc file and included in your units.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: can defines be made global ?
« Reply #2 on: August 30, 2018, 12:50:46 pm »
Compile with -dSomesymbol

Bart

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: can defines be made global ?
« Reply #3 on: August 30, 2018, 12:57:50 pm »
Compile with -dSomesymbol

Bart

Thank you Taazz and thank you Bart.  Bart, I will take your answer. (geez..  I should have thought about that...)
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: can defines be made global ?
« Reply #4 on: August 30, 2018, 01:24:10 pm »
Compile with -dSomesymbol

Do a build-all with -dsomesymbol.

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: can defines be made global ?
« Reply #5 on: August 30, 2018, 02:15:48 pm »
Compile with -dSomesymbol

Do a build-all with -dsomesymbol.

Indeed, build, to ensure the defined symbol applies to the entire program.  Thank you Marco.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: can defines be made global ?
« Reply #6 on: August 30, 2018, 02:19:51 pm »
Do a build-all with -dsomesymbol.
The Project Options -> Compiler Options -> Custom Options pane in Lazarus has a nice GUI for defines. It remembers the earlier used ones.
A build-all is done automatically after compiler options change.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: can defines be made global ?
« Reply #7 on: August 30, 2018, 02:28:43 pm »
Do a build-all with -dsomesymbol.
The Project Options -> Compiler Options -> Custom Options pane in Lazarus has a nice GUI for defines. It remembers the earlier used ones.
A build-all is done automatically after compiler options change.
Yes, it does and, I used that to put my defines in there. :) 
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018