error in header file socket.h

4 次查看(过去 30 天)
jiji hr
jiji hr 2016-5-2
评论: jiji hr 2016-5-6
Hi, I encouter this error while compilation after adding the header file socket.h to the include repertory of visual studio.10 and I am using matlab 2013. this is the log error file :
perform_front_propagation_anisotropic.cpp
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(119) : error C2146: syntax error : missing ';' before identifier 'sa_len'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(119) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(119) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(120) : error C2146: syntax error : missing ';' before identifier 'sa_family'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(120) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(120) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(129) : error C2146: syntax error : missing ';' before identifier 'sp_family'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(129) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(129) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(130) : error C2146: syntax error : missing ';' before identifier 'sp_protocol'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(130) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(130) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(173) : error C2146: syntax error : missing ';' before identifier 'msg_name'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(173) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(173) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(174) : error C2146: syntax error : missing ';' before identifier 'msg_namelen'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(174) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(174) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(176) : error C2146: syntax error : missing ';' before identifier 'msg_iovlen'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(176) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(176) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(177) : error C2146: syntax error : missing ';' before identifier 'msg_control'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(177) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(177) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(178) : error C2146: syntax error : missing ';' before identifier 'msg_controllen'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(178) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(178) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(197) : error C2146: syntax error : missing ';' before identifier 'cmsg_len'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(197) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(197) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(222) : error C2146: syntax error : missing ';' before identifier 'sa_family'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(230) : error C2146: syntax error : missing ';' before identifier 'msg_name'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(230) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(230) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(234) : error C2146: syntax error : missing ';' before identifier 'msg_accrights'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(234) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(234) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sys/socket.h(240) : fatal error C1083: Cannot open include file: 'sys/cdefs.h': No such file or directory
any help would be appreciated;
  2 个评论
Walter Roberson
Walter Roberson 2016-5-2
For a C++ program, shouldn't you #include <socket> rather than #include <socket.h> ?
jiji hr
jiji hr 2016-5-6
I don't think so sir, if that was the problem it should tell me that the file socket.h doesn't existe, but it is a problem with the socket.h file. Any way I think I found the problem where it is after paying attention to the contente of the file, I am actually working on windows, and It seems that i included i Unix File, so instead of including socket.h I had to include winsock2.h.
Thank you so much for your interaction.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by