Weird compile error dealing with Winnt.h

后端 未结 1 739
感动是毒
感动是毒 2021-01-13 05:30

When trying to compile a file that include winnt.h via windows.h, I get the following error:

MyGl.cpp
..\\microsoft sdks\\windows\\v6.0a\\include\\winnt.h(964) : e         


        
相关标签:
1条回答
  • 2021-01-13 06:01

    There are at least two ways to do this. The first is to simply include windows.h at the top of all your files. Then include winnt.h only if you need it. However, I find this a bit too much - I don't see the need of including all this goo in every single file.

    What I do is this at the very top (first thing) in my C/C++ header files.

    #ifndef __wtypes_h__
    #include <wtypes.h>
    #endif
    
    #ifndef __WINDEF_
    #include <windef.h>
    #endif
    

    This will get you you the data types, defines, and fundamental Windows API's. You may also need to add the following:

    #ifndef _WINUSER_
    #include <winuser.h>
    #endif
    
    #ifndef __RPC_H__
    #include <rpc.h>
    #endif
    

    WinNT is a bit of a special animal - don't include it if including the above files works for you. If you do need it, include it after wtypes.h and `windef.h'

    If this doesn't work, then check your include paths and predefined macros to see if those might be breaking your build.

    Regards, Foredecker

    0 讨论(0)
提交回复
热议问题