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

조회 수: 2 (최근 30일)
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 CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by