MATLAB Answers

0

S-Function String Parameter C++

Asked by Nils Gerke on 13 Aug 2018 at 6:42
Latest activity Edited by Nils Gerke on 13 Aug 2018 at 6:44

Hey,

I've trouble reading the value of a string passed to MATLAB as an S-Function parameter in C++:

std::string str(mxArrayToString(ssGetSFcnParam(S,0)));

Throws the following exception:

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).

For debugging purposes I splitted it up:

const mxArray* pArrayValue = ssGetSFcnParam(S,0);
const char* pCharArray = mxArrayToString(pArrayValue);
std::string str(pCharArray);

pCharArray points to:

0x000000000000000

I am using VS 14.0.25431.01 Update 3 on Win 10 Pro 17134.165 with Matlab 2018a. I found code in our companies repository where both of the above code snippets are working, in MATLAB 2013b, what am I doing wrong? Is this syntax invalid in 2018a?

  0 Comments

Sign in to comment.

Products


Release

R2018a

0 Answers