cangjie-annotation

Explain Cangjie SDK built-in annotations for compilation, performance, and deprecation.

2|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/zhenzhizhi12/NexusAgent --skill cangjie-annotation-zhenzhizhi12
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-annotation
Source: https://github.com/zhenzhizhi12/NexusAgent/tree/main/.opencode/skills/common-skill-l1/annotation
Command: npx skills add https://github.com/zhenzhizhi12/NexusAgent --skill cangjie-annotation-zhenzhizhi12

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers understand and effectively use Cangjie SDK's built-in annotations for source code location, conditional compilation, performance optimization, ABI stability, metadata tagging, and deprecation management.

Core Features & Use Cases

  • Source Location: Get package, file, and line number information.
  • Conditional Compilation: Selectively compile code based on OS, architecture, or debug mode using @When.
  • Performance: Optimize C interop calls with @FastNative.
  • ABI Stability: Ensure backward compatibility with @Frozen.
  • Metadata: Add runtime metadata with @Attribute.
  • Deprecation: Mark APIs as deprecated with migration guidance using @Deprecated.

Quick Start

Explain the usage and best practices for the @When annotation in Cangjie.

Frequently Asked Questions about cangjie-annotation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use annotations in Cangjie for conditional compilation?

Use the `@When` annotation in Cangjie to selectively compile code based on OS, architecture, or debug mode. This conditional compilation mechanism ensures only relevant code paths are built for the target environment.

What is the `@Frozen` annotation used for in Cangjie SDK?

The `@Frozen` annotation in the Cangjie SDK ensures backward compatibility by freezing the ABI. It guarantees that existing Application Binary Interfaces remain stable across subsequent SDK updates without breaking dependent code.

How can I optimize C interop performance in Cangjie?

Apply the `@FastNative` annotation to optimize C interop calls in Cangjie. This annotation reduces overhead during native function execution, directly tuning performance for cross-language operations.

How do I mark deprecated APIs and provide migration guidance in Cangjie?

Use the `@Deprecated` annotation to mark obsolete APIs in Cangjie. It allows developers to attach migration guidance directly within the source code, ensuring clear transitions away from deprecated functions.

Can I get source code location details like file and line number in Cangjie?

Yes, Cangjie provides built-in source location annotations to retrieve package, file, and line number information. This metadata attribution helps trace execution paths and debug code efficiently.

How does runtime metadata tagging work with the Cangjie compiler?

Runtime metadata tagging in Cangjie works by applying the `@Attribute` annotation to classes or functions. This embeds custom metadata directly into the compiled output for reflection and runtime inspection.