Main Content

Integrate External C/C++ Code Using C Function Blocks

Integrate and call external C/C++ code from a Simulink model

Use theC Functionblock to call external C/C++ code from your model. Use theC Functionblock to:

  • Write C code to preprocess data to call a C function. Similarly, you can write C code to postprocess data after calling a C function.

  • Specify different code for simulation and code generation.

  • 调用多个C函数中定义您的外部code.

  • Initialize and work with persistent data cached in the block.

Use theC Functionblock in cases where you need to allocate and deallocate memory, preprocess and postprocess external code symbols, or initialize and terminate persistent data. To call simple C code, use theC Callerblock. To integrate a dynamic system using C code into your Simulink®model, use theS-Functionblock.

Blocks

C Function Integrate and call external C/C++ code from a Simulink model

Objects

SymbolSpec Query and configure C Function block data symbols
Symbol C Function block data symbol