Add operating system target symbols to conditional compilation
- Status
- Fixed
- Fixed in
- v26.10.4
- Area
- compiler ide
- Source discussion
- https://forum.objo.dev/d/1394-targetwindows-conditional-macro
- Last updated
- 2026-10-30
Upvotes
1 upvote
Uses your Objo forum account.
Public summary
Add TargetWindows, TargetMacOS, and TargetLinux to conditional compilation so developers can include platform-specific source only when building for the corresponding operating system.
Runtime checks such as If System.IsWindows Then choose which compiled code executes, but both branches still have to compile. They cannot protect a reference to an API or declaration that is unavailable for another platform. Operating-system target symbols would allow those declarations and references to be excluded before parsing and type checking:
@If TargetWindows Then
# Windows-specific declarations and code
@ElseIf TargetMacOS Then
# macOS-specific declarations and code
@ElseIf TargetLinux Then
# Linux-specific declarations and code
@EndIf
The symbols must describe the operating system being targeted, including cross-platform builds and remote execution. They are independent of the existing project-type symbols such as TargetDesktop and of DebugBuild and TestBuild. Runtime System.IsWindows, System.IsMacOS, and System.IsLinux remain appropriate for decisions about the OS on which an application is actually running.