Modify

Opened 4 months ago

Closed 7 weeks ago

Last modified 7 weeks 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.

Attachments (0)

Change History (7)

comment:1 Changed 7 weeks ago by Brian Catlin <BrianC@…>

Component: Nonewinapi
Owner: set to Andrey Semashev

comment:2 Changed 7 weeks ago by Andrey Semashev

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 Changed 7 weeks ago by Brian Catlin <BrianC@…>

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 Changed 7 weeks ago by Andrey Semashev

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 Changed 7 weeks ago by Brian Catlin <BrianC@…>

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 Changed 7 weeks ago by Brian Catlin <BrianC@…>

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

comment:7 Changed 7 weeks ago by Andrey Semashev

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Andrey Semashev.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.