How to inline external C-Code with legacy code tool?
2 次查看(过去 30 天)
显示 更早的评论
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
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!