I am using the latest Visual Studio 2022 / C++ / MFC, Windows SDK 10.0, Platform toolset 10.0 (latest installed version), C++ Language Standard ISO C++ 17 Standard and building 64 bit.
I started with the standard MDI template, added some stuff (Scintilla edit control, which requires >= ISO C++ 17) and successfully compiled.
Now I'm integrating existing source code from previous development (which compiles under ISO C++ 14, but that may not be the explanation for what I'm about to describe).
My compile is now failing with the following errors:
Error C1189 #error: CTaskDialog is not supported on Windows versions prior to Vista. Visual SQL Studio C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\atlmfc\include\afxtaskdialog.h 18
... and
Error C2664 'INT getaddrinfo(PCSTR,PCSTR,const ADDRINFOA *,PADDRINFOA *)': cannot convert argument 1 from 'LPCTSTR' to 'PCSTR' Visual SQL Studio C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\atlmfc\include\atlsocket.h 163
So, not in my code. In both cases, there is conditional compilation based on Windows version #defines. For example, for the first error, the code is:
#if (NTDDI_VERSION < NTDDI_VISTA) // min Windows Vista required
#error CTaskDialog is not supported on Windows versions prior to Vista.
#endif
My interpretation of this is that the compiler sees value of NTDDI_VERSION as less than the value of NTDDI_VISTA and therefore fires the error.
BUT, I am only using all of the defaults created by the project template for pch.h, framework.h and targetver.h, which (if my understanding is correct) equates to
#include <SDKDDKVer.h>
.
So, I'm scratching my head on the explanation or cure for this issue. I am definitely not redefining Windows version #defines elsewhere. However, I think
NTDDI_VERSION
is actually undefined at the point in the header file where the version test is applied, because this edit (sacrilege, I know) causes the compile to succeed:
#undef NTDDI_VERSION
#define NTDDI_VERSION NTDDI_WIN10
#if (NTDDI_VERSION < NTDDI_VISTA) // min Windows Vista required
#error CTaskDialog is not supported on Windows versions prior to Vista.
#endif
Clearly editing AfxTaskDialog.h is not an acceptable solution, so I'd be incredibly grateful for any suggestion on how to diagnose / resolve this issue.
Summary of framework/platfirm defines
pch.h - #include "framework.h" as first line.
framework.h - #include "targetver.h" as first line
targetver.h - #include <sdkddkver.h> as first line
What I have tried:
I have explicitly #defined NTDDI_VERSION in pch.h and / or framework.h and / or targetver.h. I have forced the NTDDI_VERSION to pass the #if (NTDDI_VERSION < NTDDI_VISTA) test by hard coding NTDDI_VERSION (which works but is not a viable solution).