Click here to Skip to main content
15,886,069 members

Comments by peterboulton (Top 11 by date)

peterboulton 25-Jan-24 13:59pm View    
I have (finally) diagnosed the issue. I noticed that the following header file is being logged in my compile output:

C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\atlmfc\src\mfc\stdafx.h

Line 21 of that file is "#undef NTDDI_VERSION".

Line 21 is the only reference to NTDDI_VERSION in the file. Not sure why it's there.

Comparing the 'Include Directories' list in Project Settings I noticed that $(IncludePath) and $(SourcePath) appeared at the top of the list of include directories referencing the existing source files I'd added to the project. I moved them to the bottom of the list, and now the project compiles! Phew.

Maxim, many thanks for all your help with this one. I would never have got to this point without your wisdom and suggestions. I will mark your response as the solution, and many thanks again!
peterboulton 25-Jan-24 13:01pm View    
Hi Maxim, actually from my last post, NTDDI_VERSION is logged at 0x0A000006 from my targetver.h compilation, not 0x0A00 (which is what I'm setting _WIN32_WINNT to). Therefore, I think the defines are right from my targetver.h, BUT by the time the compiler gets to afxtaskdialog.h the _WIN32_WINNT is still 0x0A00 but NTDDI_VERSION is now undefined. I'm at a loss to understand why or how to trace the #undef. I just searched for the text "#undef NTDDI_VERSION" in "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0" but there were no results. :-((
peterboulton 25-Jan-24 12:08pm View    
Hi Maxim. This was a new project. It compiled fine until I added the existing source files from another project... but only .cpp and .h files, so I would assume my problem is not caused by old project files.
peterboulton 25-Jan-24 12:00pm View    
Hi Maxim - many thanks for your patience with me!
So, the compile order is:
stdafx.cpp
stdafx.h
framework.h
targetver.h
SDKDDKVer.h

stdafx.h includes framework.h which includes targetver.h.

Following your suggestions, I have the following in targetver.h:

#define _WIN32_WINNT _WIN32_WINNT_WIN10
#define NTDDI_VERSION NTDDI_WIN10_RS5
#include <sdkddkver.h>

// Echo #define value to compiler output
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#pragma message("Targetver.h: NTDDI_VERSION = " TOSTRING(NTDDI_VERSION) ", _WIN32_WINNT = " TOSTRING(_WIN32_WINNT))

In the build log, this results in:

Targetver.h: NTDDI_VERSION = 0x0A000006, _WIN32_WINNT = 0x0A00

... which is right, yes? I want to build for Windows 10 forwards.

If I re-use the same approach by editing the afxtaskdialog.h (a Microsoft file):

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#pragma message("afxtaskdialog.h: NTDDI_VERSION = " TOSTRING(NTDDI_VERSION) ", _WIN32_WINNT = " TOSTRING(_WIN32_WINNT))

#if (NTDDI_VERSION < NTDDI_VISTA) // min Windows Vista required
#error CTaskDialog is not supported on Windows versions prior to Vista.
#endif

... I get this in the build output:

afxtaskdialog.h: NTDDI_VERSION = NTDDI_VERSION, _WIN32_WINNT = 0x0A00

My take on this is that NTDDI_VERSION has been #undef'd somewhere (not in my code). Do you agree?

In which case, I am baffled as to where it is being #undef'd or how to locate it. If you have any suggestions I would (continue to be) so, so grateful!

Many thanks.
peterboulton 24-Jan-24 8:56am View    
You mean, like this (in stdafx.h, which I'm using instead of pch.h [changed in precompiled header settings section]):

// stdafx.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.

#define _WIN32_WINNT 0x0a00

Unfortunately, same issues. :-((