S-Function builder, #define directive

9 次查看(过去 30 天)
Hey guys,
I am a beginner in Simulink and already built a few S-Functions using the S-Function Builder and C-Code which I have written earlier.
Now, as a project I am trying to implement a large C-code from an automotive ECU in an existing vehicle model. It contains over 200 Header files, which are included depending on the type of hardware with which the vehicle is equipped (gearbox, engine etc.). To differentiate between the types the #define directive is used. For example:
#if (a == 1)
#include "Header_a.h"
#else
#include "Header_b.h"
#endif
Is it possible to include these routines in the S-Function Builder? Can I just add the case discrimination in the 'Libraries' section via 'includes'?
Thank you very much in advance!
Jonny
  1 个评论
Lucas Lebert
Lucas Lebert 2016-12-8
Hi Jonny, it seems that you are already quite experienced with the S-Function builder. Nevertheless I would like to give some background: The S-Function Builder creates two c-source files (among other files). When the name of your S-Function is MySFunction they are named MySFunction.c and MySFunction_wrapper.c. The directives, which you have specified in the Includes pane of the S-Function Builder is listed at the top of the file MySFunction_wrapper.c and usually starts with a comment like the following: /* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */ So generally, it is possible to use the #if directive there. But to make a statement to your specific use case I would need to know, where the variable a comes from.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by