IntelliSense error identifier “emlrtStack” is undefined

风流意气都作罢 提交于 2019-12-25 02:34:48

问题


I am converting a MATLAB written function into C by "Matlab coder". After I get the converted files , the converted function always have first input argument as const emlrtStack *sp. Now when I am trying to test it on VC++ 2013, IntelliSense is giving mentioned above error.

I manually tried to locate this identifier in emlrt.h file but no such thing is present there. I tried to convert a simple multiply function with two input arguments[like, c=mul(a,b)] but still the converted function has this extra argument inside the function in addition to a and b. (which means this argument is not function specific).

If someone has a solution to this or have experienced a problem like this, please share or help.

Moreover If someone know how to simply test these converted functions, it would be a much appreciated additional help .


回答1:


It is likely that the code that was generated for a MEX function rather than a standalone target. MEX functions are binaries written C, C++ or Fortran that can be called like a normal MATLAB function. Generating code to produce a MEX function allows two things. First, you can test your generated code in MATLAB because you can call the MEX function from MATLAB like any other function. Look for a file named mul_mex.mex* after you do code generation and try to call it: mul_mex(1,2). The other use for generating a MEX function is that it can often be faster than the MATLAB code from which it was generated. MEX functions are only used in the context of MATLAB.

The parameter emlrtStack* that you saw appears in MEX generated code to aid in runtime error reporting. It is not present in standalone code that is designed to be run outside of MATLAB.

If you want to use the generated code in Visual Studio, or outside of MATLAB you should choose one of the standalone targets, LIB, DLL, or EXE. This page shows how to change the output type. To summarize, if using the command line you could say:

cfg = coder.config('lib'); %or 'dll' or 'exe'
codegen mul -config cfg -args {1,2}

If using the project interface, you click on the Build tab and choose static library or shared library in the "Output type" dropdown menu.

I would recommend reading this example that demonstrates how to use a generated DLL in Visual Studio.



来源:https://stackoverflow.com/questions/26000459/intellisense-error-identifier-emlrtstack-is-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!