S-Function builder, #define directive

9 views (last 30 days)
Jonathan Merz
Jonathan Merz on 7 Dec 2016
Commented: Lucas Lebert on 8 Dec 2016
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 Comment
Lucas Lebert
Lucas Lebert on 8 Dec 2016
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.

Sign in to comment.

Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!