Discussion:
Including Winsock2.h causing compile errors
(too old to reply)
Charles R
2009-10-27 18:14:01 UTC
Permalink
I've included Winsock2.h in header file and i'm getting compile errors in the
QOS.h file. I have not edited neither winsock2.h or qos.h.

I have a project w/ multiple configurations. I created a new configuration
copying an existing one. Both use the same files and include winsock2.h (and
ws2_32.lib). The difference is the new configuration includes different
libraries and has different additional include directories. I comment out
including Winsock2.h and it compiles, I uncomment it and it fails. Below are
the compile errors.

Any ideas? TIA
-C



c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2238: unexpected token(s) preceding ';'
Scott McPhillips [MVP]
2009-10-27 21:13:16 UTC
Permalink
Try including winsock2.h before windows.h
Post by Charles R
I've included Winsock2.h in header file and i'm getting compile errors in the
QOS.h file. I have not edited neither winsock2.h or qos.h.
I have a project w/ multiple configurations. I created a new configuration
copying an existing one. Both use the same files and include winsock2.h (and
ws2_32.lib). The difference is the new configuration includes different
libraries and has different additional include directories. I comment out
including Winsock2.h and it compiles, I uncomment it and it fails. Below are
the compile errors.
Any ideas? TIA
-C
c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2238: unexpected token(s) preceding ';'
--
Scott McPhillips [VC++ MVP]
Tim Roberts
2009-10-28 07:05:17 UTC
Permalink
Post by Charles R
I've included Winsock2.h in header file and i'm getting compile errors in the
QOS.h file. I have not edited neither winsock2.h or qos.h.
...
Any ideas? TIA
c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2238: unexpected token(s) preceding ';'
One of your files has #defined the symbol "Length" to some constant, as in:
#define Length 17
and is being included before qos.h.

That's a very dangerous thing, as exemplified here. qos.h has structures
with members named "Length". As a first pass, use all caps for your
symbols:
#define LENGTH 17

But the better plan is to use a meaningful name:
#define IN_BUFFER_LENGTH 17
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Tim Roberts
2009-10-28 07:05:17 UTC
Permalink
Post by Charles R
I've included Winsock2.h in header file and i'm getting compile errors in the
QOS.h file. I have not edited neither winsock2.h or qos.h.
...
Any ideas? TIA
c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2238: unexpected token(s) preceding ';'
One of your files has #defined the symbol "Length" to some constant, as in:
#define Length 17
and is being included before qos.h.

That's a very dangerous thing, as exemplified here. qos.h has structures
with members named "Length". As a first pass, use all caps for your
symbols:
#define LENGTH 17

But the better plan is to use a meaningful name:
#define IN_BUFFER_LENGTH 17
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Scott McPhillips [MVP]
2009-10-27 21:13:16 UTC
Permalink
Try including winsock2.h before windows.h
Post by Charles R
I've included Winsock2.h in header file and i'm getting compile errors in the
QOS.h file. I have not edited neither winsock2.h or qos.h.
I have a project w/ multiple configurations. I created a new configuration
copying an existing one. Both use the same files and include winsock2.h (and
ws2_32.lib). The difference is the new configuration includes different
libraries and has different additional include directories. I comment out
including Winsock2.h and it compiles, I uncomment it and it fails. Below are
the compile errors.
Any ideas? TIA
-C
c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(433) : error
C2238: unexpected token(s) preceding ';'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2059: syntax error : 'constant'
c:\program files\microsoft visual studio\vc98\include\qos.h(450) : error
C2238: unexpected token(s) preceding ';'
--
Scott McPhillips [VC++ MVP]
Loading...