MATLAB: Do I get an identifier “RTWSfcnInfo” is undefined error when building a model that contains S-functions for a custom target in Real-Time Worshop 6.3 (R14SP3)

grtrtwrtwsfcninfos-functionsfcnsfunctionsimulink coder

When I build my model that contains S-functions using a custom target based off of GRT, I get the following errors:
"model.c", line 565: error: identifier "RTWSfcnInfo" is undefined
"model.c", line 565: error: identifier "sfcnInfo" is undefined
My model builds fine when I remove the S-Functions, or build with GRT.

Best Answer

The RTWSfcnInfo struct is defined in sfcn_bridge.h, which needs to be included when the model is built, by the target template makefile (TMF). The TMF has to define USE_RTMODEL. Our GRT target does it with the following lines of its TMF:
#------------------------ rtModel ----------------------------------------------
RTM_CC_OPTS = -DUSE_RTMODEL
This definition starts a whole cascade of dependencies that allows you to use non-inlined S-functions. The RTM_CC_OPTS token is then inserted under the "C Flags" section.