Main Content

Standard math library

Description

Specify standard math library for model.

Category: Code Generation > Interface

Settings

Default: C99 (ISO) or, if Language is set to C++, C++03 (ISO)

C89/C90 (ANSI)

Generates calls to the ISO®/IEC 9899:1990 C standard math library.

C99 (ISO)

Generates calls to the ISO/IEC 9899:1999 C standard math library.

C++03 (ISO)

Generates calls to the ISO/IEC 14882:2003 C++ standard math library.

C++11 (ISO)

Generates calls to the ISO/IEC 14882:2011 C++ standard math library.

Tips

  • Before setting this parameter, verify that your compiler supports the library you want to use. If you select a parameter value that your compiler does not support, compiler errors can occur.

  • If you are using a compiler that does not support ISO/IEC 9899:1999 C, set this parameter to C89/C90 (ANSI).

  • The build process checks whether the specified standard math library and toolchain are compatible. If they are not compatible, a warning occurs during code generation and the build process continues.

  • If you specify this parameter for a Linux® gcc build process, the software adds compiler flags to enforce the specified language standard. For example, if you set this parameter to C89/90 (ANSI) , the software specifies:

    • For C code: -ansi -pedantic

    • For C++ code: -std=c++98 -pedantic

    If the build process includes custom code that does not conform with the version of the language standard, for example, custom C++ code that uses C++11 features, then the code might fail to compile.

    If your model is configured to use a toolchain for building code, use this workaround:

    1. In the Configuration Parameters dialog box, set Build configuration to Specify.

    2. Under Toolchain details, in the C Compiler and C++ Compiler Options fields, replace C_STANDARD_OPTS and CPP_STANDARD_OPTS with your required compiler flags, omitting -pedantic and flags that specifies a language standard. You can determine default values for C_STANDARD_OPTS and CPP_STANDARD_OPTS by inspecting a previously generated makefile.

Dependencies

  • C++03 is available for use only if you select C++ for the Language parameter.

  • When you change the value of the Language parameter, the standard math library updates to C99 (ISO) for C and C++03 (ISO) or C++11 (ISO) for C++.

Command-Line Information

Parameter: TargetLangStandard
Type: character vector
Value: 'C89/C90 (ANSI)' | 'C99 (ISO)' | 'C++03 (ISO)' | 'C++11 (ISO)'
Default: For C, 'C99 (ISO)'; for C++ 'C++03 (ISO)'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyValid library
Safety precautionNo impact

Related Topics