Recent

Author Topic: how to disable directive  (Read 4710 times)

helio

  • New Member
  • *
  • Posts: 29
how to disable directive
« on: April 19, 2018, 05:35:26 pm »
how to disable {$IFNDEF VerboseAnchorSide} ?

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: how to disable directive
« Reply #1 on: April 19, 2018, 06:09:42 pm »
What an odd question. Really ... it puzzles me.

If you wish for that statement to be ignored then just put two slashes in front of it or change it into:
Code: [Select]
{.$IFNDEF VerboseAnchorSide}
note the dot in front of $

Don't forget to to the same for the matching {$ENDIF}

Oh, and recompile your LCL (as i'm guessing that is what you refer to).

Seems like someone made a mistake using ndef, as it doesn't make much sense this way. But what do i know  :)

metis

  • Sr. Member
  • ****
  • Posts: 300
Re: how to disable directive
« Reply #2 on: April 19, 2018, 06:34:26 pm »
@helio

molly left out the most aggressive Way to meet this Challenge:

Delete the Line, and
don't forget to do the same with the matching {$ENDIF}. :)

Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how to disable directive
« Reply #3 on: April 19, 2018, 06:49:46 pm »
Code: Pascal  [Select][+][-]
  1. {$IFDEF VerboseAnchorSide}
  2. {$UNDEFINE VerboseAnchorSide}
  3. {$ENDIF}
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

helio

  • New Member
  • *
  • Posts: 29
Re: how to disable directive
« Reply #4 on: April 19, 2018, 07:28:08 pm »
wanted to disable it without having to change the lcl.
through my application!!!

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11351
  • FPC developer.
Re: how to disable directive
« Reply #5 on: April 19, 2018, 07:29:25 pm »
For the case where this is not true, define an extra define ReallyNotDefinedVerboseAnchorSide and change to

{$if not defined(VerboseAnchorSide) and defined(ReallyNotDefinedVerboseAnchorSide)}
...
{$ifend}

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how to disable directive
« Reply #6 on: April 21, 2018, 10:15:32 am »
wanted to disable it without having to change the lcl.
through my application!!!
sorry defines are unit bound can not be defined or changed outside the unit.
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

Thaddy

  • Hero Member
  • *****
  • Posts: 14158
  • Probably until I exterminate Putin.
Re: how to disable directive
« Reply #7 on: April 21, 2018, 11:18:36 am »
wanted to disable it without having to change the lcl.
through my application!!!
sorry defines are unit bound can not be defined or changed outside the unit.
That is not  entirely correct. You can disable a define globally from the command line (using -u<SomeDefine>) and you can also enable it globally (using -d<SomeDefine>)
In Lazarus you can use these commands in your project settings.
Note this ony works for -ALL- units, NOT the main program. Defines in the main program override the command line instead.
Small demo:
Code: Pascal  [Select][+][-]
  1. unit definetest;
  2. interface
  3. {$define test}
  4. implementation
  5. initialization
  6.   {$ifdef test}
  7.   writeln('test is defined');
  8.   {$else}
  9.   writeln('test is not defined');
  10.   {$endif}
  11. end.
Code: Pascal  [Select][+][-]
  1. program testdefines;
  2. {$ifdef fpc}{$mode delphi}{$H+}{$endif}
  3. uses definetest;
  4. begin
  5. end.
Code: Bash  [Select][+][-]
  1. pi@raspberrypi:~ $ fpc -utest testdefines.pas
  2. Free Pascal Compiler version 3.1.1-r38795 [2018/04/20] for arm
  3. Copyright (c) 1993-2018 by Florian Klaempfl and others
  4. Target OS: Linux for ARMHF
  5. Compiling testdefines.pas
  6. Linking testdefines
  7. 10 lines compiled, 0.8 sec
  8. pi@raspberrypi:~ $ ./testdefines
  9. test is not defined
Code: Bash  [Select][+][-]
  1. pi@raspberrypi:~ $ fpc testdefines.pas
  2. Free Pascal Compiler version 3.1.1-r38795 [2018/04/20] for arm
  3. Copyright (c) 1993-2018 by Florian Klaempfl and others
  4. Target OS: Linux for ARMHF
  5. Compiling testdefines.pas
  6. Linking testdefines
  7. 6 lines compiled, 0.8 sec
  8. pi@raspberrypi:~ $ ./testdefines
  9. test is defined




« Last Edit: April 21, 2018, 11:44:44 am by Thaddy »
Specialize a type, not a var.

Thaddy

  • Hero Member
  • *****
  • Posts: 14158
  • Probably until I exterminate Putin.
Re: how to disable directive
« Reply #8 on: April 21, 2018, 01:05:33 pm »
All this means of course that -uVerboseAnchorSide and -dVerboseAnchorSide will work from the command line.  Or Lazarus project settings for the compiler.
« Last Edit: April 21, 2018, 01:23:23 pm by Thaddy »
Specialize a type, not a var.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how to disable directive
« Reply #9 on: April 21, 2018, 02:56:07 pm »
wanted to disable it without having to change the lcl.
through my application!!!
sorry defines are unit bound can not be defined or changed outside the unit.
That is not  entirely correct. You can disable a define globally from the command line (using -u<SomeDefine>) and you can also enable it globally (using -d<SomeDefine>)
In Lazarus you can use these commands in your project settings.
ahh, good to know there is such a construct, now how I make sure it does not work in my units?
Note this ony works for -ALL- units, NOT the main program. Defines in the main program override the command line instead.
well as long as the define is explit inside the unit then I argue it should take presence over all command line arguments but hey not interested enough to debate about it.
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

Thaddy

  • Hero Member
  • *****
  • Posts: 14158
  • Probably until I exterminate Putin.
Re: how to disable directive
« Reply #10 on: April 21, 2018, 04:21:14 pm »
ahh, good to know there is such a construct, now how I make sure it does not work in my units?
Define in your main program. (*.lpr or the one that says program...) that will override it. Otherwise you can't override the command line.
Quote
Note this ony works for -ALL- units, NOT the main program. Defines in the main program override the command line instead.
Quote
well as long as the define is explit inside the unit then I argue it should take presence over all command line arguments but hey not interested enough to debate about it.
It does not....as per my example....Only the main program file overrides the command line.
You can't have it both ways...
« Last Edit: April 21, 2018, 04:27:10 pm by Thaddy »
Specialize a type, not a var.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how to disable directive
« Reply #11 on: April 21, 2018, 07:11:27 pm »
ahh, good to know there is such a construct, now how I make sure it does not work in my units?
Define in your main program. (*.lpr or the one that says program...) that will override it. Otherwise you can't override the command line.
Quote
Note this ony works for -ALL- units, NOT the main program. Defines in the main program override the command line instead.
Quote
well as long as the define is explit inside the unit then I argue it should take presence over all command line arguments but hey not interested enough to debate about it.
It does not....as per my example....Only the main program file overrides the command line.
You can't have it both ways...
I do not want it both ways.
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

Thaddy

  • Hero Member
  • *****
  • Posts: 14158
  • Probably until I exterminate Putin.
Re: how to disable directive
« Reply #12 on: April 21, 2018, 09:01:09 pm »
I do not want it both ways.
Good. :) ;) :D
Specialize a type, not a var.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: how to disable directive
« Reply #13 on: April 21, 2018, 11:14:21 pm »
I do not want it both ways.
Good. :) ;) :D
thank you! Your approval means a lot. Now can I disable it?
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

Thaddy

  • Hero Member
  • *****
  • Posts: 14158
  • Probably until I exterminate Putin.
Re: how to disable directive
« Reply #14 on: April 22, 2018, 06:50:29 am »
Summary:
- {$define}/{$undef} works on a code block basis, not a unit basis
- You can override both globally using the -u and -d options  from the compiler for any unit or code block except the main project file
- You can not use -u and -d to override defines in the main project file: those will take precedence - that might be a bug, btw, not sure, any thoughts? -.
- You likely need the -B option (full rebuild) as well to guarantee proper behavior.

Basically you can not prevent this behavior. You either use these options or not.
I usually don't use these options, but rely on what is specified in the sourcecode.(except for -dDEBUG and -dRELEASE).
It can have unwanted side effects.
Specialize a type, not a var.

 

TinyPortal © 2005-2018