Sign in Join

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

Mailing lists / lazarus / 2016-04

where do I put project wide conditional define?

7 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

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

Mattias Gaertner
to Dennis
Show quoted text 14 lines
I some of my units, I have : uses classes, {$IFDEF USE_XYZ} certain_unitXYZ {$ENDIF}; Where do I put {$DEFINE USE_XYZ} so that when I rebuild the project, fpc will see USE_XYZ is defined. Putting in in the project .lpr does not work

Add -dUse_XYZ to
Project / Project Options / Compiler Options / Custom Options

Mattias

Reply by email

Graeme Geldenhuys
to Dennis: I some of my units, I have : {$IFDEF USE_XYZ} certain_unitXYZ {$ENDIF}; Where do I put…
Dennis wrote
so that when I rebuild the project, fpc will see USE_XYZ is defined.

You have multiple options.

Depending on your Lazarus version... In older versions of Lazarus IDE you have to define then in "Project Options -> Compiler Options -> Other" and enter them in the "Custom options" memo box.

If you don't always compile you project with Lazarus IDE, or switch to other IDE's on occasion, you can also use include file in the header of each of your units in your project.

eg:

==================================
program mytestapp;
{$I mydefines.inc}

uses
....
==================================

==================================
unit mytestunit;
{$I mydefines.inc}
interface

uses
....
==================================

The mydefines.inc file will contain things like

  {$mode objfpc}
  {$define SomeDefine}
  {.$define release}  // this one is disabled for now
  {$define debug}
  etc.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email