# Are there DAML pre-compiler conditions

**URL:** <https://forum.canton.network/t/are-there-daml-pre-compiler-conditions/7163>\
**Category:** App Development\
**Tags:** daml\
**Created:** [March 14, 2024, 9:11pm UTC](https://forum.canton.network/t/are-there-daml-pre-compiler-conditions/7163 "2024-03-14T21:11:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cohen.avraham](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cohen.avraham](https://forum.canton.network/u/cohen.avraham)\
**Post date:** [March 14, 2024, 9:11pm UTC](https://forum.canton.network/t/are-there-daml-pre-compiler-conditions/7163/1 "2024-03-14T21:11:53Z")

</div>

G-d willing

Hello,  
I would like to control the debug statements in my code using a precompiled condition. So, it will be turned on in the dev environment, and in production, it will be off.  
So, eventually, I will have something like

```haskell
{-# PrecompilerCondition = True #-}

-- Some DAML code

{-# IF PrecompilerCondition #-}
debug "Hello"
{-# ENDIF PrecompilerCondition #-}

```

Thanks,  
Avraham

---

<div class="post-metadata">

**Author:** ![akrmn](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/akrmn/32/2484_2.png) [@akrmn](https://forum.canton.network/u/akrmn)\
**Post date:** [March 15, 2024, 11:25am UTC](https://forum.canton.network/t/are-there-daml-pre-compiler-conditions/7163/2 "2024-03-15T11:25:58Z")

</div>

Hello @cohen.avraham,

Daml’s GHC foundations mean that it inherits GHC’s support for CPP, so the code you want would look something like this

```haskell
{-# LANGUAGE CPP #-}

-- the usual style for CPP macros is SNAKE_CASE_ALL_CAPS
#define PRECOMPILER_CONDITION 

module Example where

import Daml.Script

test : Script ()
test = do
#ifdef PRECOMPILER_CONDITION
  debug "Hello"
#endif
  pure ()

```

It is also possible to define CPP macros in flags to `daml` commands instead of defining them within the daml source files, e.g.

`daml build --ghc-option -DPRECOMPILER_CONDITION`, but note that you will also need to define the macros in subsequent invocations of e.g. `daml test`, so `daml test --ghc-option -DPRECOMPILER_CONDITION`.

For a third option, you can add CPP macro definitions in your project’s `daml.yaml`, under `build-options`:

```yaml
# daml.yaml
sdk-version: 2.8.3
name: example
version: 0.0.1
source: daml
dependencies:
- daml-prim
- daml-stdlib
- daml-script
build-options: [--ghc-option=-DPRECOMPILER_CONDITION]

```

Note, however, that there’s currently a bug ([daml#17821](https://github.com/digital-asset/daml/issues/17821)) in our IDE that prevents it from working properly on projects with `CPP` pragmas. Working through the command line with `daml build` and `daml test` should be fine, however.
