Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-01

Conditional define via Build mode?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers

Hi all,

I'm trying to set a conditional symbol depending on build mode. I've got Debug and Release build modes defined.

In code, I can do this:
  {$DEFINE DEBUG}
  {$IFDEF DEBUG}
  writeln('Debug: ' + Message);
  {$ENDIF DEBUG}

How can I set DEBUG only when in Debug build mode? I had a look at the wiki page and the Project Options, Build Macros but I'm a bit lost.

I just added DEBUG:=1 to the Conditionals screen... but that doesn't seem to do the trick... I've tried playing with adding macros but must just be missing something elementary...

Thanks,
Reinier

Reply by email

Mattias Gaertner
to Reinier Olislagers
Show quoted text 17 lines
Hi all, I'm trying to set a conditional symbol depending on build mode. I've got Debug and Release build modes defined. In code, I can do this: {$DEFINE DEBUG} {$IFDEF DEBUG} writeln('Debug: ' + Message); {$ENDIF DEBUG} How can I set DEBUG only when in Debug build mode? I had a look at the wiki page and the Project Options, Build Macros but I'm a bit lost. I just added DEBUG:=1 to the Conditionals screen... but that doesn't seem to do the trick... I've tried playing with adding macros but must just be missing something elementary...

You have to separate IDE macros and FPC macros.
FPC macros are defined via the Compiler Options / Custom options, e.g. -dDEBUG.

The "DEBUG:=1" sets an IDE macro.

Mattias

Reply by email

Reinier Olislagers
to Mattias Gaertner
Mattias Gaertner wrote 18 lines
On Fri, 06 Jan 2012 16:01:50 +0100 Reinier Olislagers wrote: > I'm trying to set a conditional symbol depending on build mode. I've got > Debug and Release build modes defined. > > In code, I can do this: > {$DEFINE DEBUG} > {$IFDEF DEBUG} > writeln('Debug: ' + Message); > {$ENDIF DEBUG} > > How can I set DEBUG only when in Debug build mode? I had a look at the > wiki page and the Project Options, Build Macros but I'm a bit lost. You have to separate IDE macros and FPC macros. FPC macros are defined via the Compiler Options / Custom options, e.g. -dDEBUG. The "DEBUG:=1" sets an IDE macro.

Thanks Matthias, that's very clear... and works ;)

Reinier

Reply by email

Elazar Dornelles Ceza
to Reinier Olislagers
Show quoted text 5 lines
> How can I set DEBUG only when in Debug build mode? I had a look at the > wiki page and the Project Options, Build Macros but I'm a bit lost. You have to separate IDE macros and FPC macros. FPC macros are defined via the Compiler Options / Custom options, e.g. -dDEBUG.

Hi, delphi has IFOTP directive to do something like this, search more about to see if can you use the same on FPC.
Here is one small example (portuguese)
http://www.evolutionsystems.com.br/?p=173

Atenc; Elazar Dornelles Ceza -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120106/d47289a2/attachment.html>

Reply by email