[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference decwet::nt-developers

Title:MS Windows NT Developers
Notice:See note 1222 for MS bug reporting info
Moderator:TARKIN::LINEIBER
Created:Mon Nov 11 1991
Last Modified:Tue Jun 03 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3247
Total number of notes:15633

3182.0. "simple program doesn't compile" by PAMSRC::XHOST::SJZ (Rocking the Messaging Desktop !) Wed Feb 05 1997 01:10

    
    the following program does not compile using the latest
    SDK.  I am using VC++ V4.2 but it would happen with any
    compiler.
    
    #define _WIN32_WINNT 0x0400
    #include <winsock2.h>
    
    main()
    {
    }
    
    problem is winsock2.h includes windows.h which includes
    winsock2.h.  then windows.h  includes  mswsock.h.  only
    problem is that we are still in the middle of including
    winsock2.h so there are definitions missing when includ-
    ing mswsock.h
    
    question is,  should this work ? the equivalent program
    using plain old winsock (not winsock 2)  compiles  with-
    out error.
    
    _sjz.
T.RTitleUserPersonal
Name
DateLines
3182.1why are you defining _WIN32_WINNT?VAXCPU::michaudJeff Michaud - ObjectBrokerWed Feb 05 1997 10:477
	I've always been told you should include windows.h before you
	include anything else.  Hence your program as coded is
	broken.

	I also question why you are defining that preprocessor
	symbol that begins with an _, which is reserved for internal
	use by the implementation.
3182.2NEWVAX::LAURENTHal Laurent @ COPWed Feb 05 1997 11:0715
re: .1

>	I also question why you are defining that preprocessor
>	symbol that begins with an _, which is reserved for internal
>	use by the implementation.

Some of the newer functions (CreateWaitableTimer is one I've run into)
have the definitions in the header files surrounded by

	#if _WIN32_WINNT > 0x400

(or something like that), but the symbol isn't defined by the Developer
Studio environment.

-Hal Laurent
3182.3It's the NT WIN32 API versionDECWET::MVBMonty VanderBiltWed Feb 05 1997 13:576
_WIN32_WINNT is the version key for the NT WIN32 API. 0400 refers to NT 4.0.
0500 will be 5.0. It's not in your environment because I believe it's
some kind of built in definition based on the machine you are on
(that's a guess). I would not try to force this definition because of
interacting dependencies between it and other components (for example,
the version of DCOM, which is a separate define). 
3182.4NEWVAX::LAURENTHal Laurent @ COPWed Feb 05 1997 14:1914
re: .3

>_WIN32_WINNT is the version key for the NT WIN32 API. 0400 refers to NT 4.0.
>0500 will be 5.0. It's not in your environment because I believe it's
>some kind of built in definition based on the machine you are on
>(that's a guess). I would not try to force this definition because of
>interacting dependencies between it and other components (for example,
>the version of DCOM, which is a separate define). 

I have VC++ V4.2 installed on a box running NT Workstation V4.0 and
_WIN32_WINNT is definitely not defined.  When I define it manually the
routines in question work just like they're supposed to.

-Hal Laurent
3182.5PAMSRC::XHOST::SJZRocking the Messaging Desktop !Wed Feb 05 1997 16:1629
    
    i just defined it for the example.  it is actually defined
    when you include win32.mak in your makefile  and  you  set
    your TARGETOS to WINNT.  the definition of _WIN32_WINNT as
    0x0400 is what causes windows.h to  choose  winsock2.h  in-
    stead of winsock.h.
    
    The reason this came up is that I am trying to switch from
    winsock to winsock2.  Specifically I am trying to build an
    application for NT V3.51,  so I can't use VC++  V4.2.  The
    windows.h for VC++ V4.1 does not know from winsock2 (which
    i am getting from the PATHWORKS 32 distribution).   In  or-
    der to get that to work you have to include winsock2.h  be-
    fore windows.h.  winsock2.h defeats inclusion of winsock.h.
    if you include windows.h first and then winsock2,  you get
    duplicate definitions because windows.h has already includ-
    ed winsock.h.   Only problem is if you include  winsock2.h
    before windows.h it doesn't compile using  VC++  V4.2.  it
    does compile if you include windows.h first. In otherwords,
    on one version you have to have A before B and on the next
    you need B before A.
    
    I was getting absolutely nowhere with my questions in  the
    PATHWORKS32 so I thought I would try here (since  winsock2
    isn't necessarily pathworks specific).  Maybe  the  answer
    is if you want winsock2 you need to use the latest  great-
    est version of the WIN32 SDK - period.
    
    _sjz.