Saturday, December 19, 2020

WARNING: _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)

ERROR / WARNING: _WIN32_WINNT not defined.

  1. Problem with _WIN32_WINNT
  2. The correct format for the define is:

    #define _WIN32_WINNT 0x0502
    and this statement must come before any #includes in the StdAfx.h, or whatever include you use to build the precompiled headers

  3. How to get rid of _WIN32_WINNT not defined warning?
  4. find and review this good thought:

    #define _WIN32_WINNT and #define WINVER can occur in a header, so long as they occur before including SDKDDKVer.h or any headers from the Windows SDK (in particular Windows.h). Visual Studio VC++ projects typically provide a targetver.h header, where you can include WinSDKVer.h, define _WIN32_WINNT, NTDDI_VERSION and WINVER, and then include SDKDDKVer.h. Comments within this file say:

  5. _win32_winnt win10_th2 is not defined as a preprocessor macro
  6. Update WINVER and _WIN32_WINNT
  7. When you use the Windows SDK, you can specify which versions of Windows your code can run on. The preprocessor macros WINVER and _WIN32_WINNT specify the minimum operating system version your code supports. Visual Studio and the Microsoft C++ compiler support targeting Windows 7 SP1 and later. Older toolsets include support for Windows XP SP2, Windows Server 2003 SP1, Vista, and Windows Server 2008. Windows 95, Windows 98, Windows ME, Windows NT, and Windows 2000 are unsupported.

    When you upgrade an older project, you may need to update your WINVER or _WIN32_WINNT macros. If they're assigned values for an unsupported version of Windows, you may see compilation errors related to these macros.

    Remarks To modify the macros, in a header file (for example, in targetver.h, which is included by some project templates that target Windows), add the following lines.

    C Copy #define WINVER 0x0A00 #define _WIN32_WINNT 0x0A00

    The macros in the example are set to target every version of the Windows 10 operating system. The possible values are listed in the Windows header file sdkddkver.h, which defines macros for each major Windows version. To build your application to support a previous Windows platform, include WinSDKVer.h. Then, set the WINVER and _WIN32_WINNT macros to the oldest supported platform before including sdkddkver.h. Here are the lines from the Windows 10 SDK version of sdkddkver.h that encode the values for each major version of Windows:

    For a more fine-grained approach to versioning, you can use the NTDDI version constants in sdkddkver.h. Here are some of the macros defined by sdkddkver.h in Windows 10 SDK version 10.0.18362.0:

  8. /D (Preprocessor Definitions)
  9. Defines a preprocessing symbol for a source file.

  10. How to get rid of _WIN32_WINNT not defined warning?
  11. MSVC:fix warning: _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)

No comments:

Post a Comment