October 12th, 2005, 06:56 AM
#1
this error, why? help me
my program can compile and run correctly earlier.
but now i compile it , show these errors:
maybe some head file was broken? How to deal with, thanks
--------------------Configuration: ping_icmp2 - Win32 Debug--------------------
Compiling...
ping.cpp
e:\microsoft visual studio\vc98\include\mswsock.h(69) : error C2065: 'SOCKET' : undeclared identifier
e:\microsoft visual studio\vc98\include\mswsock.h(69) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\mswsock.h(69) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\mswsock.h(73) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\mswsock.h(89) : error C2146: syntax error : missing ')' before identifier 'hSocket'
e:\microsoft visual studio\vc98\include\mswsock.h(89) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\mswsock.h(96) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\mswsock.h(101) : error C2146: syntax error : missing ')' before identifier 'sListenSocket'
e:\microsoft visual studio\vc98\include\mswsock.h(101) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\mswsock.h(109) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\mswsock.h(131) : error C2146: syntax error : missing ')' before identifier 'hSocket'
e:\microsoft visual studio\vc98\include\mswsock.h(131) : error C2165: 'left-side modifier' : cannot modify pointers to data
e:\microsoft visual studio\vc98\include\mswsock.h(131) : error C2071: 'LPFN_TRANSMITFILE' : illegal storage class
e:\microsoft visual studio\vc98\include\mswsock.h(138) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\mswsock.h(146) : error C2146: syntax error : missing ')' before identifier 'sListenSocket'
e:\microsoft visual studio\vc98\include\mswsock.h(146) : error C2165: 'left-side modifier' : cannot modify pointers to data
e:\microsoft visual studio\vc98\include\mswsock.h(146) : error C2071: 'LPFN_ACCEPTEX' : illegal storage class
e:\microsoft visual studio\vc98\include\mswsock.h(154) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(85) : error C2378: 'SOCKET' : redefinition; symbol cannot be overloaded with a typedef
e:\microsoft visual studio\vc98\include\winsock2.h(101) : error C2146: syntax error : missing ';' before identifier 'fd_array'
e:\microsoft visual studio\vc98\include\winsock2.h(101) : error C2501: 'SOCKET' : missing storage-class or type specifiers
e:\microsoft visual studio\vc98\include\winsock2.h(101) : error C2501: 'fd_array' : missing storage-class or type specifiers
e:\microsoft visual studio\vc98\include\winsock2.h(104) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1422) : error C2143: syntax error : missing ';' before '__stdcall'
e:\microsoft visual studio\vc98\include\winsock2.h(1422) : error C2501: 'SOCKET' : missing storage-class or type specifiers
e:\microsoft visual studio\vc98\include\winsock2.h(1422) : error C2370: 'SOCKET' : redefinition; different storage class
e:\microsoft visual studio\vc98\include\winsock2.h(1424) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1424) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1424) : error C2501: 'accept' : missing storage-class or type specifiers
e:\microsoft visual studio\vc98\include\winsock2.h(1427) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1445) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1445) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1445) : error C2491: 'bind' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1448) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1467) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1467) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1467) : error C2491: 'closesocket' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1467) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1483) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1483) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1483) : error C2491: 'connect' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1486) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1504) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1504) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1504) : error C2491: 'ioctlsocket' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1507) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1525) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1525) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1525) : error C2491: 'getpeername' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1528) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1546) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1546) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1546) : error C2491: 'getsockname' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1549) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1567) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1567) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1567) : error C2491: 'getsockopt' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1572) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1660) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1660) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1660) : error C2491: 'listen' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1662) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1713) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1713) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1713) : error C2491: 'recv' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1717) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1736) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1736) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1736) : error C2491: 'recvfrom' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1742) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1788) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1788) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1788) : error C2491: 'send' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1792) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1811) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1811) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1811) : error C2491: 'sendto' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1817) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1838) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1838) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1838) : error C2491: 'setsockopt' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1843) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1863) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(1863) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(1863) : error C2491: 'shutdown' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(1865) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(1880) : error C2143: syntax error : missing ';' before '__stdcall'
e:\microsoft visual studio\vc98\include\winsock2.h(1880) : error C2501: 'SOCKET' : missing storage-class or type specifiers
e:\microsoft visual studio\vc98\include\winsock2.h(1880) : error C2370: 'SOCKET' : redefinition; different storage class
e:\microsoft visual studio\vc98\include\winsock2.h(2349) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(2349) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(2349) : error C2491: 'WSAAsyncSelect' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(2353) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(2399) : error C2143: syntax error : missing ';' before '__stdcall'
e:\microsoft visual studio\vc98\include\winsock2.h(2399) : error C2501: 'SOCKET' : missing storage-class or type specifiers
e:\microsoft visual studio\vc98\include\winsock2.h(2399) : error C2370: 'SOCKET' : redefinition; different storage class
e:\microsoft visual studio\vc98\include\winsock2.h(2401) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(2401) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(2401) : error C2501: 'WSAAccept' : missing storage-class or type specifiers
e:\microsoft visual studio\vc98\include\winsock2.h(2406) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(2443) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(2443) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(2443) : error C2491: 'WSAConnect' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(2450) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(2489) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(2489) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(2489) : error C2491: 'WSADuplicateSocketA' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(2492) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(2497) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(2497) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(2497) : error C2491: 'WSADuplicateSocketW' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(2500) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(2535) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(2535) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(2535) : error C2491: 'WSAEnumNetworkEvents' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(2538) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(2602) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(2602) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(2602) : error C2491: 'WSAEventSelect' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(2605) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(2623) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(2623) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(2623) : error C2491: 'WSAGetOverlappedResult' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(2628) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(2648) : error C2146: syntax error : missing ')' before identifier 's'
e:\microsoft visual studio\vc98\include\winsock2.h(2648) : warning C4229: anachronism used : modifiers on data are ignored
e:\microsoft visual studio\vc98\include\winsock2.h(2648) : error C2491: 'WSAGetQOSByName' : definition of dllimport data not allowed
e:\microsoft visual studio\vc98\include\winsock2.h(2651) : error C2059: syntax error : ')'
e:\microsoft visual studio\vc98\include\winsock2.h(2651) : fatal error C1003: error count exceeds 100; stopping compilation
Error executing cl.exe.
ping.obj - 102 error(s), 27 warning(s)
October 12th, 2005, 07:03 AM
#2
Re: this error, why? help me
for the vc6 can't support the CreatWaitableTimer, i add "
#define _WIN32_WINNT 0x400" into the WINSOCK2.H,
if i del it from the WINSOCK2.H, it work normally but can not identify the
"CreatWaitableTimer "function, how should i do?
October 12th, 2005, 07:40 AM
#3
Re: this error, why? help me
Why are you editing winsock2.h, should you not be adding the #define to your own header ?
October 12th, 2005, 08:24 AM
#4
Re: this error, why? help me
yes, then i add the define before the include statements in my source code.
but still failed to compile. it has hundreds of errors as before.
so...i really don't know how to deal with..
October 12th, 2005, 11:54 AM
#5
Re: this error, why? help me
Or may be your are not defining it at the proper place. If the header get included before your define, you'll endup at the same place, with all these errors again. Therefore, make sure that you define before including windows header.
October 12th, 2005, 09:18 PM
#6
Re: this error, why? help me
code as this: but still failed to compile. it has hundreds of errors as before.
Code:
#define _WIN32_WINNT 0x400
#include "iostream.h"
#include "winsock2.h"
#include "stdio.h"
#include "windows.h"
#include "stdlib.h"
#define ICMP_ECHO_REQUEST 8
#define ICMP_ECHO_REPLY 0
#define ICMP_DEST_UNREACH 3
#define ICMP_TTL_EXPIRE 11
.....
October 12th, 2005, 11:26 PM
#7
Re: this error, why? help me
make a .zip file of your project (exclude debug/release folders) and post it here.
October 13th, 2005, 01:14 AM
#8
Re: this error, why? help me
This is my source code. Plz check...Thanks
Attached Files
October 13th, 2005, 01:50 AM
#9
Re: this error, why? help me
here is fixed version of ur code.
Attached Files
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
October 13th, 2005, 02:55 AM
#10
Re: this error, why? help me
Thanks a lot. And where did u modify?
October 13th, 2005, 03:09 AM
#11
Re: this error, why? help me
I have just change the sequence of included header files
Code:
#define _WIN32_WINNT 0x400
#include "windows.h"
#include "iostream.h"
#include "winsock2.h"
#include "stdio.h"
#include "stdlib.h"
moving windows.h at top of other included files.
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
October 13th, 2005, 03:26 AM
#12
Re: this error, why? help me
May 25th, 2006, 06:03 PM
#13
Re: this error, why? help me
hello guys!
I tried building the "working" verison of the attached code, but I am getting redefinition errors. Because the code uses winsock2.h, when it opens it, it says that all definitions have already been done in winsock.h, so it give raise an error tryign to redefine them.
I am confused, how come it is taking the definitions of winsock.h even though it is not included in the code? Is it becasue the windows.h might include winsock.h by default? I am using window XP, is that related?
thanks,
aHAB
May 25th, 2006, 07:46 PM
#14
Re: this error, why? help me
With due deference to Naumann's expertise, I tend to disagree with him on the order of the #include's.
winsock2.h belongs before windows.h, not after it. The reason (as you suspected) is that windows.h itself includes the basic winsock.h file. To prevent its inclusion, the winsock2 .h header includes the following
which will prevent the later inclusion of winsock.h
Mike
May 25th, 2006, 11:49 PM
#15
Re: this error, why? help me
Originally Posted by
MikeAThon
winsock2.h belongs before windows.h, not after it.
U r right but at that time when i was posting such reply i did not looked at this specific Widnows.h and winsock2.h relation. Even did not realize that if u delete such #include winsock2.h from that code it can also compile and run successfully. Anayways thanks for correction.
Last edited by Naumaan; May 26th, 2006 at 01:52 PM .
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width