How to inline external C-Code with legacy code tool?

2 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2020 年 9 月 30 日
回答済み: MathWorks Support Team 2020 年 12 月 3 日
I am calling external C functions via an S-function. The S-function is created using Legacy Code Tool (LCT), which also generates a TLC file.
Despite the TLC file, the external C code is not inlined when generating C code. What is the correct workflow to inline the external C code?

採用された回答

MathWorks Support Team
MathWorks Support Team 2020 年 9 月 30 日
You can use #ifdef MATLAB_MEX_FILE pragma in your external header file to control compiler function inline process
Assume we would inline external code: myfoo.c, myfoo.h
Step 1: Add pragma to your external header file myfoo.h e.g.
#ifdef MATLAB_MEX_FILE // This is for simulation only, we create empty functions
void myfoo(uint32_t instance, uint8_t channel);
#else // Code generation
#include "a.h"
#include "b.h"
static inline void myfoo(uint32_t instance, uint8_t channel)
{
...
}
#endif
Step 2: The myfoo.c contains this
#include "myfoo.h"
#ifdef MATLAB_MEX_FILE // This is for simulation only, we create empty functions
void myfoo(uint32_t instance, uint8_t channel
{
}
#endif
In the model step function, the external code will be inlined after compiling code from your Simulink model.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

タグ

タグが未入力です。

製品


リリース

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by