Feedback
Add target symbols to conditional compilation
- Status
- Fixed
- Fixed in
- v26.10.2
- Area
- compiler
- Source discussion
- https://forum.objo.dev/d/1070-web-containercontrol
- Last updated
- 2026-10-12
Upvotes
0 upvotes
Uses your Objo forum account.
Public summary
Conditional compilation (@If ... Then / @ElseIf / @Else / @EndIf) currently defines two compiler symbols: DebugBuild and TestBuild. Neither can tell shared code which project type it is being compiled for, so a solution with a Desktop project and a Web project cannot keep one copy of shared code that references a desktop-only API such as ContainerControl or HTMLViewer: the Web compilation fails on the unknown type.
Requested change: add compiler-defined target symbols to conditional-compilation conditions.
TargetDesktop,TargetWeb,TargetCommandLine, andTargetWorkerareTruewhen the compilation targets that project type.- Exactly one target symbol is true per compilation. Shared code is compiled once per consuming project, so the same source selects the right branch in each target's build.
- Example: shared code in a solution with a Desktop project and a Web project can branch around a desktop-only API, and each target's build compiles cleanly:
@If TargetDesktop Then
WalkContainer(sidebar) # sidebar is a ContainerControl, desktop-only today
@Else
WalkWebGroup(group) # group is a GroupBox on the web target
@EndIf
- The symbols work like
DebugBuild: usable only inside directive conditions, not in ordinary code or constant initialisers.DebugBuildandTestBuildsemantics are unchanged.