The different implementation of 'rtIsNan' function is due to using Microsoft Visual C++ compiler during code generation. If Microsoft Visual Compiler is used for code generation, then RTW generated code contains reference to _isnan() function which is shipped with the compiler.
This can be verified in the MSDN documentation page below:
<http://msdn.microsoft.com/en-us/library/aa298428
For example, following is the generated code with Real-Time Workshop R2007a, R2007b, R2008a and R2008b, when Microsoft Visual C++ 2005 was NOT selected as the compiler:
boolean_T rtIsNaN(real_T value)
{
return((value!=value) ? 1U : 0U);
}
Following is the generated code in R2007a,R2007b and R2008a, when Microsoft Visual C++ 2005 was the selected compiler:
boolean_T rtIsNaN(real_T value)
{
/* For MSVC 6.0, must use the compiler specific comparison function */
return _isnan(value)? 1U:0U;
}
As you can observe above, when MS Visual Compiler is used, there is a reference to _isnan. Therefore when you package this into an archive for compilation using a different compiler, this would result in an error.
However in R2008b, even with MS VC as the selected compiler, the code generated contains appropriate pre-processor directives to handle this situation. Following is the code generated in R2008b when MS VC is selected as compiler::
boolean_T rtIsNaN(real_T value)
{
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
/* For MSVC 6.0, use a compiler specific comparison function */
return _isnan(value)? 1U:0U;
#else
return((value!=value) ? 1U : 0U);
#endif
}
_MSC_VER is MS VC specific directive explained in the link below:
<http://msdn.microsoft.com/en-us/library/b0084kay.aspx>
To summarize, there are two workarounds to this issue:
1. Execute "mex -setup" in your MATLAB and change the current compiler to a non-Microsoft compiler.
2. Please generate code using R2008b or later versions.
Best Answer