cangjie-ffi

Call C functions from Cangjie and map C data types.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enables developers to integrate Cangjie code with existing C libraries and systems, allowing for efficient interoperability and leveraging the strengths of both languages.

Core Features & Use Cases

  • Foreign Function Interface (FFI): Declare and call C functions directly from Cangjie.
  • Type Mapping: Supports mapping of fundamental C types, structs, pointers, and arrays to Cangjie equivalents.
  • Memory Management: Provides tools for safe memory allocation and deallocation when interacting with C.
  • Callback Handling: Enables C code to call back into Cangjie functions.
  • Use Case: Integrate a high-performance C-based image processing library into your Cangjie application for faster image manipulation.

Quick Start

Use the cangjie-ffi skill to declare a C function named add that takes two integers and returns their sum, then call it from Cangjie.

Frequently Asked Questions about cangjie-ffi

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

FAQPage Schema
How do I call C functions from Cangjie?

You call C functions from Cangjie by declaring the function signature through a Foreign Function Interface, which bridges the two languages and allows direct invocation.

Can I map C structs and pointers to Cangjie data types?

Yes, you can map C structs and pointers to Cangjie equivalents. The FFI supports mapping fundamental C types, structs, pointers, and arrays across the language boundary.

How do I handle memory allocation when integrating C code with Cangjie?

Memory management across the C and Cangjie boundary is handled using provided tools for safe memory allocation and deallocation, ensuring resources are correctly freed when interacting with native code.

Does Cangjie support C callbacks into native code?

Yes, Cangjie supports C callbacks. The FFI enables C code to call back into Cangjie functions and defines calling conventions to ensure correct execution flow across languages.

What is the best way to integrate a C library into a Cangjie application?

The best way to integrate a C library into a Cangjie application is using a Foreign Function Interface, which enables efficient interoperability and lets you leverage existing high-performance C systems.