Main Content

Change the Language Standard

By default, the code generator selects a language standard based on the language that you specify in the build settings using the TargetLang parameter. If TargetLang is set to C, the default language standard is C99 (ISO). If TargetLang is set to C++, the default language standard is C++11 (ISO).

You can further specify the language standard by setting the TargetLangStandard parameter to 'C89/C90 (ANSI)', 'C99 (ISO)', 'C++03 (ISO)', or 'C++11 (ISO)'.

Compared to C89/C90 (ANSI), certain additional C language features can be used in the generated code if the language standard is C99 (ISO), including:

  • Variable scoping

  • The INFINITY and NAN macros

  • The isinf and isnan functions

  • Boolean literals

Compared to C++03 (ISO), certain additional C++ language features can be used in the generated code if the language standard is C++11 (ISO), including:

  • Enumeration classes

  • Explicitly defaulted special member functions

  • Uniform initialization syntax using {}

You can only select the C++03 (ISO) and C++11 (ISO) standards if TargetLang is set to C++. If you select a C language standard (TargetLangStandard) with the target language (TargetLang) set to C++, the code generator will use the C math libraries available in the selected standard and C++03 language features. The following combinations of language standards and math libraries are available:

Library NameLanguage SupportStandard
C89/C90 (ANSI)C, C++ISO®/IEC 9899:1990
C99 (ISO)C, C++ISO/IEC 9899:1999
C++03 (ISO)C++ISO/IEC 14882:2003
C++11 (ISO)C++ISO/IEC 14882:2011(E)

To change the TargetLangStandard, use one of these approaches:

  • In the project build settings, on the Custom Code tab, set the Language standard parameter.

  • In a code configuration object, set the TargetLangStandard parameter.

Verify that your compiler supports the library that you want to use. If you select a library that your compiler does not support, compiler errors can occur.

Related Topics