15,885,985 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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. :-((
peterboulton
24-Jan-24 8:38am
View
Sorry... CodeProject appears to let me edit your posts! I hope I've restored it, and sorry!
My targetver.h content is:
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <sdkddkver.h>
That seems correct?
I'm sorry this is so convoluted and really appreciate your help. I know it will most likely be something basic but I've been banging my head against a brick wall for a couple of days on this!
peterboulton
24-Jan-24 7:16am
View
Yes, but the _VS2008_ is my 'invention' and only used for conditional compilation of my known code. I don't believe it has any other function in the code.
My other projects also define it and compile correctly (though for C++ ISO 14, not 17).
peterboulton
24-Jan-24 6:58am
View
Hi Maxim, the C/C++ project settings command line is:
/JMC /Yu"stdafx.h" /ifcOutput "x64\Debug\" /GS /W3 /wd"4996" /Zc:wchar_t /I"G:\Visual Studio 2022 Projects\Visual SQL Studio (C++)\ScriptDomUtils" /ZI /Gm- /Od /sdl /Fd"x64\Debug\vc143.pdb" /Zc:inline /fp:precise /D "_WINDOWS" /D "_DEBUG" /D "_USE_PCH" /D "_CRT_SECURE_NO_WARNINGS" /D "_VS2008_" /D "_UNICODE" /D "UNICODE" /D "_AFXDLL" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /showIncludes /MDd /std:c++17 /FC /Fa"x64\Debug\" /EHsc /nologo /Fo"x64\Debug\" /Fp"x64\Debug\Visual SQL Studio.pch" /diagnostics:column
I can't see an issue there... can you?
Thanks again for your kindness.
peterboulton
24-Jan-24 6:54am
View
Hi Maxim. The project was created from Visual Studio 2022, current version.
peterboulton
24-Jan-24 6:32am
View
Hi Maxim. Many thanks for taking the trouble to answer my question - much appreciated. On the first issue, choosing "show includes", the first few lines of the compiler output are:
1>stdafx.cpp
1>Note: including file: G:\Visual Studio 2010 Projects\Visual SQL Studio (C++)\Visual SQL Studio\stdafx.h
1>Note: including file: G:\Visual Studio 2010 Projects\Visual SQL Studio (C++)\Visual SQL Studio\framework.h
1>Note: including file: G:\Visual Studio 2010 Projects\Visual SQL Studio (C++)\Visual SQL Studio\targetver.h
1>Note: including file: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\SDKDDKVer.h
1>Note: including file: C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\atlmfc\include\afxwin.h
So, they are compiled before the file which fires the compile error. I also tried moving SDKDDKVer.h to the first line of pch.h, but the error still fires.
On the second error, I would like to stay UNICODE and am not even aware of any of my code calling getaddrinfo(). I didn't paste in the code that triggers the error, which is from atlsocket.h. But it's the same sort of error on the version #defines as my first error. The code in AtlSocket.h is:
#if _WIN32_WINNT < 0x0502
#ifdef _UNICODE
USES_CONVERSION_EX;
const char * pszHost = W2CA_EX(szHost, _ATL_SAFE_ALLOCA_DEF_THRESHOLD);
const char * pszPortOrServiceName = W2CA_EX(szPortOrServiceName, _ATL_SAFE_ALLOCA_DEF_THRESHOLD);
if(pszHost == NULL || pszPortOrServiceName == NULL )
{
WSASetLastError(WSA_NOT_ENOUGH_MEMORY);
return SOCKET_ERROR;
}
#else
const char * pszHost = szHost;
const char * pszPortOrServiceName = szPortOrServiceName;
#endif
return ::GetAddrInfo(pszHost, pszPortOrServiceName, &hints, &m_pAddrs);
#else
return ::GetAddrInfo(szHost, szPortOrServiceName, &hints, &m_pAddrs);
#endif
If the #define was successfully defined as >= 0x502 then the other version of the function would be compiled and (I think) I would not get this compile error.
Thank you, again, for your help.
peterboulton
29-Oct-13 8:17am
View
Reason for my vote of 1 \n Waste of space. Who, with the remotest interest in sql, would not know this already?
Show More