Program: C:\windows\SYSTEM32\MSVCP140D.dll
File: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring
Line: 1181
Expression: invalid null pointer
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
MATLAB.exe has triggered a breakpoint.
Exception thrown at 0x00007FFB6C9A0A63 (test.mexw64) in MATLAB.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
> throw_segv_longjmp_seh_filter()
throw_segv_longjmp_seh_filter(): invoking THROW_SEGV_LONGJMP SEH filter
> throwSegvLongjmpFilter()
MATLAB.exe has triggered a breakpoint.
The program '[19672] MATLAB.exe' has exited with code 0 (0x0).
#define S_FUNCTION_LEVEL 2
#define S_FUNCTION_NAME sfun_pass_string
#include "simstruc.h"
#include <string>
static void mdlInitializeSizes(SimStruct *S)
{
ssSetNumSFcnParams(S, 1);
ssSetSFcnParamTunable(S, 0, SS_PRM_NOT_TUNABLE);
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
return;
}
if (!ssSetNumInputPorts(S,1)) return;
ssSetInputPortWidth(S, 0, DYNAMICALLY_SIZED);
ssSetInputPortDirectFeedThrough(S, 0, 1);
if (!ssSetNumOutputPorts(S, 1)) return;
ssSetOutputPortWidth(S, 0, DYNAMICALLY_SIZED);
ssSetNumSampleTimes(S, 1);
ssSetOptions(S, SS_OPTION_CALL_TERMINATE_ON_EXIT);
}
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, INHERITED_SAMPLE_TIME);
ssSetOffsetTime(S, 0, 0.0);
ssSetModelReferenceSampleTimeDefaultInheritance(S);
}
#define MDL_START
static void mdlStart(SimStruct *S)
{
mexPrintf("class of parameter: %s", mxGetClassName(ssGetSFcnParam(S,0)));
const mxArray* pArrayValue = ssGetSFcnParam(S,0);
const char* pCharArray = mxArrayToString(pArrayValue);
std::string string_1(pCharArray);
mexPrintf(string_1.c_str());
}
static void mdlOutputs(SimStruct *S, int_T tid)
{
}
static void mdlTerminate(SimStruct *S)
{
}
#ifdef MATLAB_MEX_FILE /* Is this file being compiled as a MEX-file? */
#include "simulink.c" /* MEX-file interface mechanism */
#else
#include "cg_sfun.h" /* Code generation registration function */
#endif
3 Comments
James Tursa (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/414621-s-function-string-parameter-c#comment_604751
Nils Gerke (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/414621-s-function-string-parameter-c#comment_604769
Titus Edelhofer (view profile)
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/414621-s-function-string-parameter-c#comment_604920
Sign in to comment.