MATLAB: Am I unable to use the PRINTF function from the standard C libraries inside the wrapper code of the C-MEX S-function

4.1r12.1s-functionsimulink

If I use the PRINTF function in my C-MEX S-function it works fine. But if I use this in some wrapper code that is called from my S-function, this function does not work. I have "#included" the standard "stdio.h" library but still have this problem.

Best Answer

You cannot use PRINTF in wrapper function code. Try using "ssPrintf" which is defined in the simstruc.h file. This will expand to 'mexPrintf' for simulation and 'printf' for real-time code. See "Writing S-functions Guide" page 10-118 for details on this macro.
You should also #include the simstruc.h file in your wrapper code when using "ssPrintf".
Related Question