Native and Conditional Compilation
This tutorial uses the CJNative SDK for Cangjie 1.2.0 to compile native executables. Running them requires the runtime libraries for the target platform, or a static-linking configuration supported by the SDK.
The @When annotation selects declarations according to the compilation target. For example, @When[backend == "cjnative"] selects the native backend implementation, while @When[arch == "x86_64"] and @When[arch == "aarch64"] select processor-specific implementations.
The example declares a getArchitecture() function for each architecture. The compiler retains only the matching declaration, so main() can call it without checking the architecture at runtime.
@When selects declarations; it cannot directly annotate expression statements such as println(). The 1.2.0 SDK pinned by this tutorial accepts only cjnative as a backend condition value. Do not add a backend == "cjvm" branch.Change the returned message and run the example to see the branch selected for the current target. Changing the target architecture also requires matching SDK tools, libraries, and an execution environment; editing a condition alone does not change the target.