Objo.
Feedback Forum Docs Objo Studio
Feedback

Feature #1704

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, and TargetWorker are True when 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. DebugBuild and TestBuild semantics are unchanged.

Objo.

Build apps visually, deploy anywhere.

Feedback is a public read-only status mirror for Objo Studio.