How to make {$ IFNDEF DEBUG} work in lazarus / osx project

I need to disable some code when running under the debugger.

So, I just imagine what to do:

{$IFNDEF DEBUG} 
  ...
{$ENDIF}

However, the code inside ifndef runs in the debugger, causing it to crash.

I have lazarus 0.9.29 and FPC 2.4.0

+3
source share
2 answers

The compiler directives you mention are actually these: compiler directives, not debug directives.

They relate to the compilation process, because it is completely separate from the debugging system.

What you need to do:

  • If you want to debug a program, define the DEBUG symbol. This will NOT compile blocks that exist inside the tests, and will not run in a debugging session.
  • , DEBUG, .

. .
, GUI, , , , .

, .

. {$ DEFINE DEBUG} - / Lazarus, .

.

+2
 {$IFOPT D-}
  //code
 {$ENDIF}

$DEBUGINFO !

0

Source: https://habr.com/ru/post/1751303/


All Articles