Hi Prakorn,
I understand you're running into a build error related to "rt_nonfinite.c" when generating code for the referenced model "Driveline". This is a known issue when using "MSVC 2022" with "Windows SDK version 10.0.26100.0".
The root cause is a change in the SDK, where NAN is no longer defined as a compile-time constant in C. Instead, it's implemented via an inline function, which causes static initializations like real_T rtNaN = NAN; in generated code (e.g., "rt_nonfinite.c") to fail with a compiler error.
In order to resolve this issue, you can try one of the following workarounds:
1. A fix for this issue seems to be included in Windows 11 SDK Build 10.0.26100.3916. Updating to this version may help resolve the problem.
2. Add the compiler flag and change the language standard:
- Go to Model Settings > Code Generation.
- Set Build configuration to "Specify".
- In C Compiler and C++ Compiler present under Toolchain details, add the flag -D_UCRT_NOISY_NAN
- Set the Language standard to "C89/C90(ANSI)" or "C++03(ISO)".
3. Switch to a different compiler:
- Use MinGW as an alternative.
- Or roll back to an earlier MSVC SDK version (before 10.0.26100.0).
To know more about this issue, refer to the following link: