Mexing s-function with compiler flag -fshort-double fails....

1 次查看(过去 30 天)
Hello,
for numerical tests of a filter algorithm implemented in C++ (testing/simulation environment is a larger simulink project) I would like to switch to single precision variables. For the gcc/g++ the option -fshort-double seems to make switching to single precision very comfortable, because it basically shrinks doubles to the size of floats.
However I get the following warning when mexing the algorithm:
/opt/matlab/v24/simulink/include/simulink.c: In function ‘int_T ssWriteRTWParamSettings(SimStruct*, int_T, ...)’: /opt/matlab/v24/simulink/include/simulink.c:1538: warning: ‘real_T’ is promoted to ‘double’ when passed through ‘...’ /opt/matlab/v24/simulink/include/simulink.c:1538: note: (so you should pass ‘double’ not ‘real_T’ to ‘va_arg’) /opt/matlab/v24/simulink/include/simulink.c:1538: note: if this code is reached, the program will abort
As stated in the warning, the simulation doesn't run, but gives the error: Invalid sizes vector returned by MEX S-function
Can this be resolved or does anybody have an alternative way of testing an S-function with single precision.
Regards, Sebastian
  2 个评论
Titus Edelhofer
Titus Edelhofer 2011-6-14
Hi Sebastian,
I understand you are writing a Simulink S-function? I would not use the flag for the compiler but tell the S-function to take single precision inputs/outputs and parameters...
Titus
Kaustubha Govind
Kaustubha Govind 2011-6-14
I agree with Titus. What you are doing will cause problems because the Simulink engine allocates and reads from signals and parameters that are supposedly double, but when it dispatched a call to MEX, it is really accessing single variables.

请先登录,再进行评论。

回答(1 个)

Wendy Fullam
Wendy Fullam 2012-9-25
Answered in comments by Titus
Hi Sebastian,
I understand you are writing a Simulink S-function? I would not use the flag for the compiler but tell the S-function to take single precision inputs/outputs and parameters...
Titus

产品

Community Treasure Hunt

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

Start Hunting!

Translated by