including source files in s-function gateway file

I am attempting to "include" a "xxx.c" file in the top s-function file that gets compiled into a ".mexw32" file. The file has the normal boiler-plate functions in it like :
static void mdlInitializeSizes( SimStruct *S ) static void mdlInitializeSampleTimes( SimStruct *S )
Etc etc
At the top of the file it looks like:
#define S_FUNCTION_NAME s_simulation #define S_FUNCTION_LEVEL 2
/******************/ /* / / INCLUDED FILES / / / /*****************/
/* reference appropriate header files */ #include "../simulation.h"
#include "../ChekFile.c" #include "../ChekFile2.c"
The header file is part of the code that currently functions OK but the last two lines do not seem to get used because when I use "dumpbin" to look in the ".mexw32" file I can't find any of the subroutines and the size of the ".mexw32" file doesn't change no matter how big I make the code for the ChekFile.c subroutines. I put calls to the subroutines in some of the boiler-plate subroutines but there doesn't seem to be a reference to them in the final ".mexw32" file.

 Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 16 de Jun. de 2011

0 votos

What dumpbin flags are you using to examine the MEX binary? I think dumpbin only displays exported functions from a DLL. Ordinarily, in a MEX-function, only the gateway function called mexFunction() is exported (the export keyword is added in mex.h). For S-functions, this is not so obvious because Simulink adds some additional instrumentation around the mdlXXX functions (this is in simulink.c, which is included at the end of all S-functions) and calls them from a mexFunction - thus, it does conform to the interface of any other MEX-function.
So if you have included source files in your S-function and are able to compile and run it successfully (I presume you already test this by calling them from one of the mdlXXX functions), you can rest assured that they have indeed been included in the MEX binary.

1 comentario

Dave
Dave el 16 de Jun. de 2011
OK, Thank you. I think I was confusing myself by using dumpbin incorrectly and looking for the final file to grow in size as I added the subroutines. I haven't run the code because it looked like it wasn't right.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Block and Blockset Authoring en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 16 de Jun. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by