Opened 8 years ago
Closed 8 years ago
#10697 closed Bugs (worksforme)
Boost coroutine leaks windows.h into global namespace
Reported by: | Owned by: | olli | |
---|---|---|---|
Milestone: | Boost 1.57.0 | Component: | coroutine |
Version: | Boost 1.56.0 | Severity: | Problem |
Keywords: | windows.h coroutine namespace | Cc: | any |
Description
I was surprised that file "boost/coroutine/windows/protected_stack_allocator.hpp" from coroutine library from boost release 1.56.0 version just insanely includes windows.h in public header without any protection from the header leaking into global namespace severely polluting it.
Because of this 'boost/coroutine/protected_stack_allocator.hpp' is rendered UNUSABLE/BROKEN on windows (all compilers) and namespace pollution may apply to Unix/Linux as well. The feature is released very hacky and unfinished way by having such code issues.
To fix this cleanly simplest thing would be to contain and move windows.h (or other platform depend) inclusion into a .cpp file which is compiled.
The file "boost/coroutine/<platform>/protected_stack_allocator.hpp" would contain function prototypes something like:
void * allocate_protected_memory(size_t) void free_protected_memory(void *)
in boost::detail namespace to just allocate protected stack memory area (no original pointer adjusting) and the protected_stack_allocator template that uses the function prototypes. The compiled file then implements the prototypes and the platform depend stuff would be hidden from library user.
Replying to jarmo.tiitto@…:
? windows.h is a system header from Windows, it is legitmi to include it in windows-related code - I don't know why you say 'insanely' etc.
it is protected by '#if defined(BOOST_WINDOWS)' - why should this pollute Unix/Linux? if you think the library is hackish - than don't use it