main.c:405: error: undefined reference to 'InitInfAndNaN', Getting this error when I'm building a .mdl Simulink Module.

10 views (last 30 days)
Im getting the above error when I'm building the .mdl modules in 2024a or 2024b but not getting when I'm using previous versions of 2024a. And also I'm not getting the error when I'm using .slx module for any version of matlab.

Answers (1)

Hitesh
Hitesh on 15 May 2025
Edited: Hitesh on 15 May 2025
Hi Veera,
The "rt_InitInfAndNaN" function is a support routine inserted automatically when your model may involve special floating-point values, such as:
  • NaN (Not a Number)
  • Inf (Infinity)
Its purpose is to initialize platform-specific representations of these values so they can be used reliably in the generated code. You need to remove this function, you must ensure that your model does not require non-finite values.
You can do this by changing the following code generation settings:
  1. Go to Model Configuration Parameters
  2. Under Code Generation > System target file : Ensure it is set to 'ert.tlc'.
  3. Go to Code Generation > Interface tab: Set "Support non-finite numbers" to OFF and Set "MAT-file logging" to OFF if not needed.
Disabling support for non-finite numbers tells Embedded Coder that your application will not use NaN, Inf, or -Inf, allowing it to omit rt_InitInfAndNaN from the generated code.
For more information regarding "rt_InitInfAndNaN", kindly refer to the following MATLAB documentation:

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!