Why Rapid Accelerator Simulation fails with Visual Studio Compiler error: "rt_nonfinite.c(4): error C2099: initializer is not a constant rt_nonfinite.c(5): error C2099: initializer is not a constant" ?

8 views (last 30 days)
I got the following error message when run Rapid Accelerator simulation using Windows SDK Version 10.0.26100.0.
** Error message **
cl -c -nologo -GS -W4 -DWIN32 @test_comp.rsp -D_MT -D_DLL -MD -D_CRT_SECURE_NO_WARNINGS -DTGTCONN -DIS_SIM_TARGET -DNRT -DRSIM_PARAMETER_LOADING -DRSIM_WITH_SL_SOLVER -DUSE_LOCALHOST -DENABLE_SLEXEC_SSBRIDGE=1 -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DON_TARGET_WAIT_FOR_START=0 -DTID01EQ=1 /DNDEBUG /Od /Oy- -DMODEL=test -DNUMST=2 -DNCSTATES=0 -DMAT_FILE=1 -DINTEGER_CODE=0 -DONESTEPFCN=0 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=1 -DALLOCATIONFCN=0 -DEXT_MODE -DIS_RAPID_ACCEL -DHAVESTDIO -DMT=0 -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 rt_nonfinite.c
rt_nonfinite.c
rt_nonfinite.c(4): error C2099: initializer is not a constant
rt_nonfinite.c(5): error C2099: initializer is not a constant
NMAKE : fatal error U1077: 'cl -c -nologo -GS -W4 -DWIN32 @test_comp.rsp -D_MT -D_DLL -MD -D_CRT_SECURE_NO_WARNINGS -DTGTCONN -DIS_SIM_TARGET -DNRT -DRSIM_PARAMETER_LOADING -DRSIM_WITH_SL_SOLVER -DUSE_LOCALHOST -DENABLE_SLEXEC_SSBRIDGE=1 -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DON_TARGET_WAIT_FOR_START=0 -DTID01EQ=1 /DNDEBUG /Od /Oy- -DMODEL=test -DNUMST=2 -DNCSTATES=0 -DMAT_FILE=1 -DINTEGER_CODE=0 -DONESTEPFCN=0 -DTERMFCN=1 -DHAVESTDIO -DMULTI_INSTANCE_CODE=0 -DCLASSIC_INTERFACE=1 -DALLOCATIONFCN=0 -DEXT_MODE -DIS_RAPID_ACCEL -DHAVESTDIO -DMT=0 -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 rt_nonfinite.c ' : return code '0x2'
Stop.
**

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 31 Jan 2025
Given this is a bug specific to Windows SDK version 10.0.26100.0 as described in https://developercommunity.visualstudio.com/t/NAN-is-no-longer-compile-time-constant-i/10688907 .
To work around the MSVC bug when generating code for a model, do one of the following:
  • Add the compiler option -D_UCRT_NOISY_NAN to the C Compiler or C++ Compiler option listed for model configuration parameter Toolchain details.
    • To change settings of model configuration parameter Toolchain details, you might need to set model configuration parameter Build configuration to Specify.
  • Set model configuration parameter Language standard to C89/C90 (ANSI) or C++03 (ISO)
    OR
  • Select a different compiler, such as MinGW, or roll back the MSVC SDK to an earlier version

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!