* * *

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

440bx

  • Sr. Member
  • ****
  • Posts: 292
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.

taazz

  • Hero Member
  • *****
  • Posts: 5337
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: 3115
    • 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

  • Sr. Member
  • ****
  • Posts: 292
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...)

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6540
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

  • Sr. Member
  • ****
  • Posts: 292
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.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3515
  • 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.

440bx

  • Sr. Member
  • ****
  • Posts: 292
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. :) 

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus