Skip to content

Document Automatically Defined Compiler Symbols in F# Compiler Directives #45607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/fsharp/language-reference/compiler-directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ let str = "Debugging!"
#endif
```

### Automatically Defined Symbols

The F# compiler automatically defines certain symbols based on the build configuration. These symbols can be used with `#if` directives for conditional compilation.

| Symbol | Description |
|---------|-------------|
| `DEBUG` | Automatically defined in debug builds when compiling with the `Debug` configuration. |
| `TRACE` | Defined when tracing is enabled in the project settings. |

For example, you can use these symbols in conditional compilation:

```fsharp
#if DEBUG
printfn "Debugging mode is enabled."
#else
printfn "Release mode."
#endif
```

These symbols are typically set by the compiler and do not require explicit definition in the source code.

## NULLABLE directive

Starting with F# 9, you can enable nullable reference types in the project:
Expand Down