Errors when compiling C++ file using legacy_code and Microsoft Visual C++ 2017
2 次查看(过去 30 天)
显示 更早的评论
I am following the steps explained here to integrate a C++ function into my simulink file. I was able to successfully run
legacy_code('sfcn_cmex_generate', def);
to create the C S-function file. However, when I tried to run
legacy_code('compile', def);
I got the following syntax errors related to cstdlib and cmath
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdlib(11): error C2061: syntax error: identifier
'noexcept'
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdlib(11): error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdlib(12): error C2449: found '{' at file scope
(missing function header?)
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdlib(14): error C2059: syntax error: '}'
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdlib(21): error C2061: syntax error: identifier
'noexcept'
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdlib(21): error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdlib(22): error C2449: found '{' at file scope
(missing function header?)
C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdlib(24): error C2059: syntax error: '}'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(9):
error C2061: syntax error: identifier 'noexcept'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(9):
error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(10):
error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(15):
error C2059: syntax error: '}'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(22):
error C2061: syntax error: identifier 'noexcept'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(22):
error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(23):
error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(25):
error C2059: syntax error: '}'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(32):
error C2061: syntax error: identifier 'noexcept'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cmath(32):
Can anybody help me fix these errors? Thank you very much.
2 个评论
Ben McMahon
2021-8-20
I do not the the specifics of this, as I have never used the legacy code functionality. However I have got similar errors when trying to include C++ files into C code using the embedded coder in Simulink. I would suggest as a starting point try ensuring the coder is set to C++.
def = legacy_code('initialize');
def.Options.language = 'C++';
However this may not be the issue at all. Be intrested to know how you get on.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!