MATLAB: DekTec DTAPI compile shows errors when compiling with e.g. Visual Studio 2017

dektec dtapimatlab 2017avisual studio 2017

Hi everybody. I hope someone can help me with my issue.
I try to load the DekTec DTAPI libraries in MATLAB with the 'loadlibrary" command: loadlibrary('./lib/VC15/DTAPI64MT.lib', './Include/DTAPI.h')
I've set the Compiler to mex -setup:C:\cax\mathworks\MATLAB\R2017a\64\bin\win64\mexopts\msvcpp2017.xml C++ MEX configured to use 'Microsoft Visual C++ 2017' for C++ language compilation.
It starts compiling, but after a while it stops with the following Errors (see below) … can anybody help me to get this stuff compiled in MATLAB 2017a? Thanks! BR, Steffen
Error loading library intermediate output follows. The actual error is at the end of this output. *******
Type '__crt_locale_dataPtr' was not found. Defaulting to type voidPtr.
Found on line 4994 of input from line 465 of file C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10586.0\\ucrt\\corecrt.h
Type '__crt_multibyte_dataPtr' was not found. Defaulting to type voidPtr.
Found on line 4994 of input from line 465 of file C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10586.0\\ucrt\\corecrt.h
Type 'longdouble' was not found. Defaulting to type error.
Found on line 9540 of input from line 425 of file C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10586.0\\ucrt\\stdlib.h
Failed to parse type 'union { unsigned short *_Sh; double _Val ; } _double_val' original input 'union { unsigned short _Sh [ 4 ]; double _Val ; } _double_val' Found on line 10600 of input from line 226 of file C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10586.0\\ucrt\\math.h
Failed to parse type 'union { unsigned short *_Sh; float _Val ; } _float_val' original input 'union { unsigned short _Sh [ 2 ]; float _Val ; } _float_val' Found on line 10607 of input from line 233 of file C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10586.0\\ucrt\\math.h
Failed to parse type 'union { unsigned short *_Sh; long double _Val ; } _ldouble_val' original input 'union { unsigned short _Sh [ 4 ]; long double _Val ; } _ldouble_val' Found on line 10614 of input from line 240 of file C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10586.0\\ucrt\\math.h
Failed to parse type 'union { unsigned short *_Word; float _Float ; double _Double ; long double _Long_double ; } _float_const' original input 'union { unsigned short _Word [ 4 ]; float _Float ; double _Double ; long double _Long_double ; } _float_const' Found on line 10622 of input from line 248 of file C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10586.0\\ucrt\\math.h
Failed to parse type 'union { unsigned short *Word; float _Float ; double _Double ; long double _Long_double ; } _Dconst' original input 'union { unsigned short _Word [ 8 ]; float _Float ; double _Double ; long double _Long_double ; } _Dconst' Found on line 11499 of input from line 41 of file C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\VC\\Tools\\MSVC\\14.10.25017\\include\\ymath.h found parens in __static_assert_t [( sizeof ( unsigned int ) <= 16 ) != 0 ] Final string:_static_assert_t [( sizeof ( unsigned int ) <= 16 ) != 0 ]
No match found for enum value expression sizeof in ( sizeof ( unsigned int ) <= 16 ) != 0 expression ignored. Found on line 23263 of input from line 84 of file C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10586.0\\ucrt\\malloc.h ******* Error using loadlibrary Building DTAPI64MT_thunk_pcwin64 failed. Compiler output is: cl -I"C:\cax\mathworks\MATLAB\R2017a\64\extern\include" /Zp8 /W3 /nologo -I"C:\cax\dektec\SDKs\WinSDK\DTAPI" -I"C:\cax\dektec\SDKs\WinSDK\DTAPI\Include" "DTAPI64MT_thunk_pcwin64.c" -LD -Fe"DTAPI64MT_thunk_pcwin64.dll" DTAPI64MT_thunk_pcwin64.c Automatically linking with DTAPI64MT.lib C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdint(9): error C2061: Syntaxfehler: Bezeichner "std" C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdint(9): error C2059: Syntaxfehler: ";" C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdint(9): error C2449: "{" auf Dateiebene gefunden – fehlt der Funktionsheader? C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\cstdint(49): error C2059: Syntaxfehler: "}" C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\xstddef(370): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_enum" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(382): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_union" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(389): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_class" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(416): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_convertible_to" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(423): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_enum" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(482): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_pod" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(489): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_empty" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(496): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_polymorphic" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(503): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_abstract" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(510): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_final" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(517): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_standard_layout" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(524): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_literal_type" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(531): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_trivial" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(538): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_trivially_copyable" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(545): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__has_virtual_destructor" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(555): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_constructible" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(592): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_assignable" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(621): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_destructible" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(631): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_trivially_constructible" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(668): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_trivially_assignable" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(697): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__has_trivial_destructor" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(707): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_nothrow_constructible" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(744): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_nothrow_assignable" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(773): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_nothrow_destructible" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(997): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__underlying_type" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\type_traits(1054): error C4233: Nicht dem Standard entsprechende Erweiterung: Schlüsselwort "__is_base_of" wird nur in C++ unterstützt und nicht in C C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\ostream(34): warning C4157: Pragma wurde vom C-Compiler ignoriert C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\ostream(611): warning C4157: Pragma wurde vom C-Compiler ignoriert C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\istream(15): warning C4157: Pragma wurde vom C-Compiler ignoriert C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\istream(884): warning C4157: Pragma wurde vom C-Compiler ignoriert DTAPI64MT_thunk_pcwin64.c(32): fatal error C1004: Unerwartetes Dateiende gefunden.

Best Answer

Hi everybody. After some further invetigation I think I found the Problem. It looks like for some files (e.g. cstdint) the C Compiler is used instead of the C++ Compiler. But as I showed before, mex is configured to use the C++ Compiler: "C++ MEX configured to use 'Microsoft Visual C++ 2017' for C++ language compilation". It Looks like the issue is, that some of the files of Visual Studio do not have any file extension like .hpp or .cpp and that for those files the C Compiler instead of the C++ Compiler is used, automatically. Is there a way (e.g. by option flag, etc.) to configure mex in such a way that it uses the C++ Compiler for files wihtout file Extension, too? Or is there any other work-around to get a successful compile flow? Thanks! BR, Steffen
Related Question