Opened 10 years ago
Closed 10 years ago
#7389 closed Bugs (fixed)
__STDC_LIMIT_MACROS can be redefined by boost when using mingw32
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | config |
Version: | Boost 1.51.0 | Severity: | Problem |
Keywords: | Cc: |
Description (last modified by )
On Windows, compiling with mingw32, STDC_LIMIT_MACROS macro is redefined if it was already defined.
This macro is defined in boost/config/platform/win32.hpp by
#if defined(__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 2) || ((__MINGW32_MAJOR_VERSION == 2) && (__MINGW32_MINOR_VERSION >= 0))) # define BOOST_HAS_STDINT_H # define __STDC_LIMIT_MACROS # define BOOST_HAS_DIRENT_H # define BOOST_HAS_UNISTD_H #endif
Maybe it can be changed to:
#if defined(__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 2) || ((__MINGW32_MAJOR_VERSION == 2) && (__MINGW32_MINOR_VERSION >= 0))) # define BOOST_HAS_STDINT_H # if !defined(__STDC_LIMIT_MACROS) # define __STDC_LIMIT_MACROS # endif # define BOOST_HAS_DIRENT_H # define BOOST_HAS_UNISTD_H #endif
Attachments (1)
Change History (10)
comment:1 by , 10 years ago
Component: | None → config |
---|---|
Owner: | set to |
by , 10 years ago
Attachment: | win32.hpp.patch added |
---|
comment:2 by , 10 years ago
Description: | modified (diff) |
---|
comment:4 by , 10 years ago
Why do we need to define
__STDC_LIMIT_MACROS
?
What happens if the user include the files using this macro before the boost config files?
follow-up: 6 comment:5 by , 10 years ago
What happens if the user include the files using this macro before the boost config files?
We have to fall back to code that doesn't depend on UINT8_MAX etc being defined. Ideally if stdint.h is included twice - once without __STDC_LIMIT_MACROS
and then again with it, it will do the right thing and fill in the definitions it missed out the first time. Not all implementations do that though :-(
comment:6 by , 10 years ago
Replying to anonymous:
What happens if the user include the files using this macro before the boost config files?
We have to fall back to code that doesn't depend on UINT8_MAX etc being defined. Ideally if stdint.h is included twice - once without
__STDC_LIMIT_MACROS
and then again with it, it will do the right thing and fill in the definitions it missed out the first time. Not all implementations do that though :-(
Isn't stdint.h protected for multiple inclusions?
follow-up: 8 comment:7 by , 10 years ago
Isn't stdint.h protected for multiple inclusions?
Maybe!
In C99 it defines different things depending on whether __STDC_LIMIT_MACROS
is defined or not, so rather like assert.h with NDEBUG
it should really "correct itself" each time it's included depending upon the value of the macro. Thankfully C++11 does the sane thing and just requires that the limit macros are always defined.
Either way, we should really try to get the system defined limits macros if we can, just because we can't be certain of getting them every time, isn't a reason not to try.
comment:8 by , 10 years ago
Replying to anonymous:
Isn't stdint.h protected for multiple inclusions?
Maybe!
In C99 it defines different things depending on whether
__STDC_LIMIT_MACROS
is defined or not, so rather like assert.h withNDEBUG
it should really "correct itself" each time it's included depending upon the value of the macro. Thankfully C++11 does the sane thing and just requires that the limit macros are always defined.
Thanks for the explanation, I didn't know about this requirement.
Either way, we should really try to get the system defined limits macros if we can, just because we can't be certain of getting them every time, isn't a reason not to try.
Agreed.
A patch