C-Code Level 2 S-Function Name

Hey,
I have a verry basic problem. I want to create a C-Code Level 2 S-Function using the mex command. I want to chance the name of the mex-file (mexw32) but not the name of the c-file.
Therefore I tried to change my trusty old friend timestwo.c.
#define S_FUNCTION_NAME sfun_timestwo
#define S_FUNCTION_LEVEL 2
#include "simstruc.h"
I tried to use the lcc-win32 and the MS SDK 7.1 compiler. My MatLab version beeing R2013a.
When I use
mex timestwo.c
the outcome is allways timestwo.mexw32 but not sfun_timestwo.mexw32.
Of cause I get an object name error when I try to run a simulation containing this S-Function.
"Error while obtaining sizes from MEX S-function 'timestwo' in 'timestwo_mdl/S-Function'.
S-function name mismatch. Name in source is "#define S_FUNCTION_NAME sfun_timestwo", whereas name of the S-function MEX file is "timestwo". The source needs to be updated"
What is the meaning of the first define (S_FUNCTION_NAME)? Isn't it possible to have different S-Function names and sorce-filce names?
Thank you in advance

Answers (1)

Walter Roberson
Walter Roberson on 2 Sep 2015
No it is not. The s-function will be loaded as a .mex* (effectively a .dll), so the name used by Simulink needs to match the name of the symbol in the file.

1 Comment

Ok. But I could rename my created S-Function to sfun_timestwo.mex*. Or could that lead to other problems?
(Right now I don't see any problems there.)

Sign in to comment.

Products

Asked:

on 2 Sep 2015

Commented:

on 2 Sep 2015

Community Treasure Hunt

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

Start Hunting!