2013-07-17 25 views
0

我是Mex的新手。在構建一個C++ Mex文件後,我在運行時立即得到這個錯誤。Mex運行時錯誤:意外的標準表達式

>> [a b c] = read_svm('/All/testhalf_Anger_1.libsvm'); 
Unexpected Standard exception from MEX file. 
What() is:basic_string::_S_construct NULL not valid 
.. 

這是我的代碼的執行看起來像

預先感謝您!

+0

調試MEX文件的東西解決這個問題-files.html – Shai

+0

相關問題:[C++:腳本中發生異常:基本\ _string :: \ _ S \ _construct NULL無效](http://stackoverflow.com/questions/12052997/c-exception-occurred-in-腳本的基本字符串-S-結構無效未有效) –

回答

2

錯誤消息很好地解釋了它,在代碼中的某個地方,您通過將NULL指針傳遞給其構造函數來構造basic_string。採用CharT *basic_string構造函數要求指針爲非NULL,因此崩潰。

請注意std::stringstd::wstringstd::basic_string類模板的typedef,因此您可能正在代碼中使用其中的一種。 http://www.mathworks.com/help/matlab/matlab_external/debugging-cc-language-mex:

您可以通過執行類似下面的代碼片段

char const *p = nullptr; 

// std::string s(p); // This is not allowed! 
std::string s(p ? p : ""); // string will be empty if p is NULL 
相關問題