Why do I receive a "C2552" compiler error when I build my model using Real-Time Workshop or Simulink Accelerator, when using a version of the Microsoft Visual C++ Compiler lower than 7.1?

3 views (last 30 days)
When I build my model, I receive the following error:
error C2552: 'MyVar' : non-aggregates cannot be
initialized with initializer list
I am using Real-Time Workshop or Simulink Accelerator with Version 6.0 or 7.0 of the Microsoft Visual C++ Compiler.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This error results from a restriction present in some versions of the Microsoft Visual C/C++ compiler. The restriction prevents code of the following format from compiling, if the code resides in a .cpp file:
struct foo {
int code;
const bool flag;
};
where the variable foo is initialized as:
static foo FTwo = {2, false };
Since Real-Time Workshop generates code of this format under some circumstances, this restriction can affect compilation of generated code.
To work around this issue, either upgrade to Version 7.1 of the Microsoft Visual C/C++ compiler, or choose the target language as C on the RTW pane of the Configuration Parameters dialog box or from the command line:
set_param(modelname,'TargetLang','C')

More Answers (0)

Categories

Find more on Manage Products in Help Center and File Exchange

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!