MATLAB: Do I receive an error when I try to generate a C++ S-function from a subsystem using right-click > Generate S-Function with MSVC 6.0 in Real-Time Workshop 6.5 (R2006b)

simulink coder

When I try to generate a C++ S-function from a subsystem using right-click > Generate S-Function with MSVC 6.0, I receive the following error:
Error_system0_sf_data.cpp(15) : error C2552: 'Error_system0_InvariantSignals' : non-aggregates cannot be initialized with initializer list
The build was successful when I set the Language in the Real-Time Workshop to C. It failed when Language is set to C++.

Best Answer

This is MSVC 6.0 compiler limitation because it does not support initialization of 'const' structure.
To workaround the issue you can do either of the following:
1. Upgrade the compiler to MSVC 7.1 or later.
or
2. Follow the steps below:
2a. Set the system target file to 'rtwsfcn.tlc'.
2b. Right-click on the subsystem block.
2c. Select Real-Time Workshop > Build Subsystem.
Note: Use "Build Subsystem" instead of "Generate S-Function". This avoids generation of 'const' structures for the parameters.