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

11 views (last 30 days)
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?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 30 Sep 2020
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.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!