Errors in stdio.h when compiling mex program with Microsoft Visual C++ 2017 Compiler

조회 수: 10 (최근 30일)
CB
CB 2019년 8월 1일
댓글: CB 2019년 8월 2일
I had previously compiled my project with the MinGW C compiler successfully. Now I want to be able to debug it and so I followed instructions here:https://www.mathworks.com/help/matlab/matlab_external/debugging-on-microsoft-windows-platforms.html
I have installed Visual Studio Professional 2017 (free trial).
Afterwards I tried to compile with this command:
mex -g -R2018a memMap.c mapping.c fileHelper.c numberHelper.c queue.c mman.c
, and got this error:
Building with 'Microsoft Visual C++ 2017 (C)'.
Error using mex
memMap.c
d:\work\matfile-parsing\v7.3files\mapping.h(7): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
So I tried adding the path to the unistd.h header file:
mex -g -R2018a -IC:\MinGW\include memMap.c mapping.c fileHelper.c numberHelper.c queue.c mman.c
and got many errors, all in header files that used to compile with the MinGW compiler:
Building with 'Microsoft Visual C++ 2017 (C)'.
Error using mex
memMap.c
C:\MinGW\include\stdio.h(38): warning C4068: unknown pragma
C:\MinGW\include\msvcrtver.h(35): warning C4068: unknown pragma
C:\MinGW\include\w32api.h(35): warning C4068: unknown pragma
C:\MinGW\include\sdkddkver.h(35): warning C4068: unknown pragma
c:\mingw\include\sys/types.h(34): warning C4068: unknown pragma
C:\MinGW\include\stdio.h(260): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(260): error C2143: syntax error: missing '{' before '*'
C:\MinGW\include\stdio.h(261): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(261): error C2143: syntax error: missing '{' before '*'
C:\MinGW\include\stdio.h(262): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(263): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(270): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(271): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(272): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(272): error C2143: syntax error: missing '{' before '*'
C:\MinGW\include\stdio.h(273): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(276): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(277): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(278): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(289): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(290): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(291): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(295): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(296): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(433): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(434): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(435): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(436): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(437): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(438): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(458): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(459): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(460): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(469): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(470): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(472): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(475): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(478): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(611): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(611): error C2061: syntax error: identifier 'getdelim'
C:\MinGW\include\stdio.h(611): error C2059: syntax error: ';'
C:\MinGW\include\stdio.h(611): error C2059: syntax error: '<parameter-list>'
C:\MinGW\include\stdio.h(614): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(614): error C2061: syntax error: identifier 'getline'
C:\MinGW\include\stdio.h(614): error C2059: syntax error: ';'
C:\MinGW\include\stdio.h(614): error C2059: syntax error: '<parameter-list>'
C:\MinGW\include\stdio.h(621): error C2143: syntax error: missing '{' before '__cdecl'
C:\MinGW\include\stdio.h(621): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(621): error C2061: syntax error: identifier 'getline'
C:\MinGW\include\stdio.h(621): error C2059: syntax error: ';'
C:\MinGW\include\stdio.h(622): error C2059: syntax error: '<parameter-list>'
C:\MinGW\include\stdio.h(630): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(631): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(632): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(636): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(637): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(638): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(639): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(640): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(641): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(642): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(651): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(652): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(689): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(690): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(691): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(692): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(698): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(698): error C2061: syntax error: identifier 'fread'
C:\MinGW\include\stdio.h(698): error C2059: syntax error: ';'
C:\MinGW\include\stdio.h(698): error C2059: syntax error: '<parameter-list>'
C:\MinGW\include\stdio.h(699): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(699): error C2061: syntax error: identifier 'fwrite'
C:\MinGW\include\stdio.h(699): error C2059: syntax error: ';'
C:\MinGW\include\stdio.h(699): error C2059: syntax error: '<parameter-list>'
C:\MinGW\include\stdio.h(703): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(704): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(705): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(756): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(757): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(761): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(762): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(772): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(773): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(780): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(780): error C2143: syntax error: missing '{' before '*'
C:\MinGW\include\stdio.h(781): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(784): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(784): error C2143: syntax error: missing '{' before '*'
C:\MinGW\include\stdio.h(785): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(790): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(791): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(792): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(793): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(793): error C2143: syntax error: missing '{' before '*'
C:\MinGW\include\stdio.h(794): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(795): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(796): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(796): error C2143: syntax error: missing '{' before '*'
C:\MinGW\include\stdio.h(849): error C2054: expected '(' to follow '__inline__'
C:\MinGW\include\stdio.h(850): error C2085: '_get_output_format': not in formal parameter list
C:\MinGW\include\stdio.h(850): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdio.h(852): error C2054: expected '(' to follow '__inline__'
C:\MinGW\include\stdio.h(853): error C2085: '_set_output_format': not in formal parameter list
C:\MinGW\include\stdio.h(853): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdio.h(874): error C2054: expected '(' to follow '__inline__'
C:\MinGW\include\stdio.h(875): error C2085: '_get_printf_count_output': not in formal parameter list
C:\MinGW\include\stdio.h(875): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdio.h(877): error C2054: expected '(' to follow '__inline__'
C:\MinGW\include\stdio.h(878): error C2085: '_set_printf_count_output': not in formal parameter list
C:\MinGW\include\stdio.h(878): error C2143: syntax error: missing ';' before '{'
C:\MinGW\include\stdio.h(882): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(883): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(884): warning C4229: anachronism used: modifiers on data are ignored
C:\MinGW\include\stdio.h(884): error C2143: syntax error: missing '{' before '*'
C:\MinGW\include\stdio.h(885): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(922): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(923): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(924): error C2059: syntax error: 'type'
C:\MinGW\include\stdio.h(924): fatal error C1003: error count exceeds 100; stopping compilation
How can I fix this? I am using MATLAB R2018b.
  댓글 수: 1
CB
CB 2019년 8월 2일
I fixed this by putting all of my code into a visual studio c++ project and compiling it from there. This let me see different errors that I couldn't see in matlab. After fixing these, I was able to remove the -I portion of the compilation command and compilation succeeded.

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by