WCHAR_MAX not defined on openbsd

hi there, i'm using openbsd 4.7 with g++ 4.2.4 installed from openbsd packages. i've tried building both boost 1.43 and 1.44rc, and both have several libraries fail due to WCHAR_MAX not being defined. this appears to be because __STDC_LIMIT_MACROS is not defined while processing /usr/include/stdint.h. i built boost with ./bjam cxxflags='-D__STDC_LIMIT_MACROS' and there are no more errors about WCHAR_MAX not being defined. perhaps this define should be added to boost/cstdint.hpp, or is there a deeper reason why WCHAR_MAX is not being defined correctly?

hi there, i'm using openbsd 4.7 with g++ 4.2.4 installed from openbsd packages. i've tried building both boost 1.43 and 1.44rc, and both have several libraries fail due to WCHAR_MAX not being defined. this appears to be because __STDC_LIMIT_MACROS is not defined while processing /usr/include/stdint.h. i built boost with ./bjam cxxflags='-D__STDC_LIMIT_MACROS' and there are no more errors about WCHAR_MAX not being defined. perhaps this define should be added to boost/cstdint.hpp, or is there a deeper reason why WCHAR_MAX is not being defined correctly?
The std doesn't specify that some magic macro has to be defined before WCHAR_MAX gets defined - in any case by the time a boost header is #included it's too late to define such a macro because the system header may have already been #included by the program. Which libraries are failing because of this? John.

On Aug 15, 2010, at 12:09 PM, John Maddock wrote:
hi there, i'm using openbsd 4.7 with g++ 4.2.4 installed from openbsd packages. i've tried building both boost 1.43 and 1.44rc, and both have several libraries fail due to WCHAR_MAX not being defined. this appears to be because __STDC_LIMIT_MACROS is not defined while processing /usr/include/stdint.h. i built boost with ./bjam cxxflags='-D__STDC_LIMIT_MACROS' and there are no more errors about WCHAR_MAX not being defined. perhaps this define should be added to boost/cstdint.hpp, or is there a deeper reason why WCHAR_MAX is not being defined correctly?
The std doesn't specify that some magic macro has to be defined before WCHAR_MAX gets defined
The C++ standard doesn't, but the C99 standard does! See footnote in 7.18.2 Limits of specified-width integer types. This is one of several places where C99 added features to C89 and notes that "C++ implementations should define these macros only when ..." some specified macro is defined before the relevant header is included.
- in any case by the time a boost header is #included it's too late to define such a macro because the system header may have already been #included by the program.
Which of course makes that C99-specified behavior a real pain to deal with. And of course that specified behavior is probably quite wrong for C++0x, but the C99 standard doesn't mention the scope of that behavior. And to add to the confusion, it is worded as a "should" rather than a "shall".

Kim Barrett wrote:
On Aug 15, 2010, at 12:09 PM, John Maddock wrote:
hi there, i'm using openbsd 4.7 with g++ 4.2.4 installed from openbsd packages. i've tried building both boost 1.43 and 1.44rc, and both have several libraries fail due to WCHAR_MAX not being defined. this appears to be because __STDC_LIMIT_MACROS is not defined while processing /usr/include/stdint.h. i built boost with ./bjam cxxflags='-D__STDC_LIMIT_MACROS' and there are no more errors about WCHAR_MAX not being defined. perhaps this define should be added to boost/cstdint.hpp, or is there a deeper reason why WCHAR_MAX is not being defined correctly?
The std doesn't specify that some magic macro has to be defined before WCHAR_MAX gets defined
The C++ standard doesn't, but the C99 standard does! See footnote in 7.18.2 Limits of specified-width integer types. This is one of several places where C99 added features to C89 and notes that "C++ implementations should define these macros only when ..." some specified macro is defined before the relevant header is included.
- in any case by the time a boost header is #included it's too late to define such a macro because the system header may have already been #included by the program.
Which of course makes that C99-specified behavior a real pain to deal with.
And of course that specified behavior is probably quite wrong for C++0x, but the C99 standard doesn't mention the scope of that behavior. And to add to the confusion, it is worded as a "should" rather than a "shall".
It is wrong for C++0x, which specifically mentions that the macros are NOT to be used in <cstdint>. §18.4.1 Bo Persson

On Aug 16, 2010, at 1:17 PM, Bo Persson wrote:
Kim Barrett wrote:
On Aug 15, 2010, at 12:09 PM, John Maddock wrote:
The std doesn't specify that some magic macro has to be defined before WCHAR_MAX gets defined
The C++ standard doesn't, but the C99 standard does! See footnote in 7.18.2 Limits of specified-width integer types. This is one of several places where C99 added features to C89 and notes that "C++ implementations should define these macros only when ..." some specified macro is defined before the relevant header is included.
And of course that specified behavior is probably quite wrong for C++0x, but the C99 standard doesn't mention the scope of that behavior. And to add to the confusion, it is worded as a "should" rather than a "shall".
It is wrong for C++0x, which specifically mentions that the macros are NOT to be used in <cstdint>. §18.4.1
That's not how I read 18.4.1. Quoting from n3092 (the most recent draft I happen to have handy), 18.4.1/2 says The header defines all functions, types, and macros the same as 7.18 in the C standard. [Note: The macros defined by <cstdint> are provided unconditionally. In particular, the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in footnotes 219, 220, and 222 in the C standard) play no role in C++. -- end note] I read that as saying that macros such as WCHAR_MAX are always defined by <cstdint>, irrespective of any definitions (or lack thereof) for __STDC_LIMIT_MACROS.

Kim Barrett wrote:
On Aug 16, 2010, at 1:17 PM, Bo Persson wrote:
Kim Barrett wrote:
On Aug 15, 2010, at 12:09 PM, John Maddock wrote:
The std doesn't specify that some magic macro has to be defined before WCHAR_MAX gets defined
The C++ standard doesn't, but the C99 standard does! See footnote in 7.18.2 Limits of specified-width integer types. This is one of several places where C99 added features to C89 and notes that "C++ implementations should define these macros only when ..." some specified macro is defined before the relevant header is included.
And of course that specified behavior is probably quite wrong for C++0x, but the C99 standard doesn't mention the scope of that behavior. And to add to the confusion, it is worded as a "should" rather than a "shall".
It is wrong for C++0x, which specifically mentions that the macros are NOT to be used in <cstdint>. §18.4.1
That's not how I read 18.4.1. Quoting from n3092 (the most recent draft I happen to have handy), 18.4.1/2 says
The header defines all functions, types, and macros the same as 7.18 in the C standard. [Note: The macros defined by <cstdint> are provided unconditionally. In particular, the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in footnotes 219, 220, and 222 in the C standard) play no role in C++. -- end note]
I read that as saying that macros such as WCHAR_MAX are always defined by <cstdint>, irrespective of any definitions (or lack thereof) for __STDC_LIMIT_MACROS.
Right. That's exactly what I meant to say. :-) Bo Persson

It is wrong for C++0x, which specifically mentions that the macros are NOT to be used in <cstdint>. §18.4.1
That's not how I read 18.4.1. Quoting from n3092 (the most recent draft I happen to have handy), 18.4.1/2 says The header defines all functions, types, and macros the same as 7.18 in the C standard. [Note: The macros defined by <cstdint> are provided unconditionally. In particular, the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in footnotes 219, 220, and 222 in the C standard) play no role in C++. -- end note] I read that as saying that macros such as WCHAR_MAX are always defined by <cstdint>, irrespective of any definitions (or lack thereof) for __STDC_LIMIT_MACROS. ~~~~~ That would be my reading too - note that C++03 lists these as required in table 95 - they're not new C++0x features. None of which resolves the original question of course... John.
participants (4)
-
Bo Persson
-
John Maddock
-
Kim Barrett
-
Nick Owens