Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#13457 closed Bugs (invalid)

Windows port for 1.66.0 incorrectly includes NTVERP.H

Reported by: Brian Catlin <BrianC@…> Owned by: Andrey Semashev
Milestone: To Be Determined Component: winapi
Version: Boost 1.66.0 Severity: Showstopper
Keywords: windows Cc:

Description

The Windows file NTVERP.H contains the version information for the SDK, and it must not be included by Boost (specifically, in lib\native\include\boost\predef\platform\windows_uwp.h) because it prevents applications from defining their own version resource, causing the compiler to complain about the version macros being redefined. In projects that are required to use the /WX (treat compiler warnings as errors) this is a fatal error. Previous versions of Boost did not have this problem.

Change History (7)

comment:1 by Brian Catlin <BrianC@…>, 4 years ago

Component: Nonewinapi
Owner: set to Andrey Semashev

comment:2 by Andrey Semashev, 4 years ago

Resolution: invalid
Status: newclosed

The boost/predef/platform/windows_uwp.h header is part of Boost.Predef. Please, report the problem here.

In my opinion though, you have to define any version macros before including *any* headers, Boost or not. And ntverp.h is essential as it allows Boost to discover Windows SDK version, I see no way around including it.

comment:3 by Brian Catlin <BrianC@…>, 4 years ago

It is common to share a Version.h header file between resource (.rc) files and source files (.cpp), to give the program access to the version information placed in the executable's version info section. Moving the definitions of the version macros before the header includes solves nothing; the macros are still re-defined because you're including NTVERP.H. Why not check to see if the macros are already defined before including NTVERP.H?

comment:4 by Andrey Semashev, 4 years ago

Arguably, you're not defining macros like VER_PRODUCTBUILD. You're not supposed to, anyway, because that is the Windows SDK version macro.

I'm not sure what version information you mean, but if this is the target Windows version defined by _WIN32_WINNT or the API family defined by WINAPI_FAMILY then defining those in a header is error-prone because it can easily get you into trouble if you mess up include order.

comment:5 by Brian Catlin <BrianC@…>, 4 years ago

In File Explorer, when you right-click on an executable and select the details tab, what you see is the version information that was stored in a resource section in the executable. As I mentioned, the most common paradigm is to define the version info in a header file (version.h), which is included by both the resource file (resources.rc) and the cpp file, thus giving the cpp file access to the version info, for outputting in a banner or in response to a -v command.

comment:6 by Brian Catlin <BrianC@…>, 4 years ago

How about putting your include of NTVERP.h into its own namespace so that you don't pollute the global namespace?

comment:7 by Andrey Semashev, 4 years ago

In File Explorer, when you right-click on an executable and select the details tab, what you see is the version information that was stored in a resource section in the executable.

I don't see how it is related to macros defined in ntverp.h. Which macros must you define in your header that are also defined in ntverp.h?

How about putting your include of NTVERP.h into its own namespace so that you don't pollute the global namespace?

We're talking about macros, they don't respect C++ namespaces.

Note: See TracTickets for help on using tickets.