#1740 closed Bugs (fixed)
date_time includes <windows.h>
Reported by: | Owned by: | az_sw_dude | |
---|---|---|---|
Milestone: | Boost 1.36.0 | Component: | date_time |
Version: | Boost 1.39.0 | Severity: | Problem |
Keywords: | windows.h date_time | Cc: |
Description
The header <boost/date_time/filetime_functions.hpp> includes <windows.h> by default, and there is no way to turn this off (e.g. BOOST_USE_WINDOWS_H). This is a problem as this brings in the min,max,ERROR,etc. macros in. (This header is included if you include <boost/date_time.hpp>
As date_time has to be compiled anyway, it would be very nice to have this functionality in the library somewhere and not include <windows.h>.
Attachments (1)
Change History (8)
follow-up: 2 comment:1 by , 15 years ago
comment:3 by , 14 years ago
This is a very serious bug for us as well as it completely breaks our entire project. It does not appear that any code which uses Windows.h is required to be inline or even public. We have yet to find a work around which allows us to build using 1.35 and have been stuck on 1.34.1.
A fix soon would be greatly appreciated.
by , 14 years ago
Attachment: | date_time.patch added |
---|
comment:4 by , 14 years ago
Please find attached a patch to solve this issue and the test report of the library on the compiler I have at my disposal. I have taken precautions in order to ensure it will work on x64 Windows (please see comments related to the conversion between FILETIME and int64) and I see no reason it should have changed for other platforms, but only testing will tell.
comment:5 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
follow-up: 7 comment:6 by , 13 years ago
Keywords: | windows.h date_time added |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
Version: | Boost 1.35.0 → Boost 1.39.0 |
If you do include windows.h anywhere in boost, you need the following two lines of code just above it:
#undef WIN32_LEAN_AND_MEAN // add this... #define WIN32_LEAN_AND_MEAN // ...and this #include <windows.h>
Otherwise, if some other 3rd party lib includes <windows.h>, it will break the build unless the header files are in a very specific order, which is extremely tedious to maintain.
comment:7 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Replying to anonymous:
If you do include windows.h anywhere in boost, you need the following two lines of code just above it:
#undef WIN32_LEAN_AND_MEAN // add this... #define WIN32_LEAN_AND_MEAN // ...and this #include <windows.h>Otherwise, if some other 3rd party lib includes <windows.h>, it will break the build unless the header files are in a very specific order, which is extremely tedious to maintain.
First, Boost.DateTime no longer includes windows.h by default. You can explicitly enable it to include windows.h by defining BOOST_USE_WINDOWS_H.
Second, defining WIN32_LEAN_AND_MEAN will disable quite a few components in windows.h. Boost.DateTime is in no position to enforce this decision in its headers. If you want windows.h to behave like when WIN32_LEAN_AND_MEAN is defined, you should define it in your project, before including any headers.
This is also breaking Asio, as Asio wants to include winsock, see: http://permalink.gmane.org/gmane.comp.lib.boost.devel/172990