Opened 13 years ago

Closed 12 years ago

Last modified 9 years ago

#3931 closed Bugs (wontfix)

Build boost libraries under HP-UX with GNU C/C++

Reported by: vovata@… Owned by: Vladimir Prus
Milestone: Boost 1.43.0 Component: program_options
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

I tried build boost, with program_options, under HP-UX (B.11.23 U ia64) with GNU C/C++ compiler version 4.3.1, using bjam. I fpund a problem with the define WCHAR_MAX in the system headers of HP-UX, it is defined there with type cast, and an error arrives in the build:

In file included from libs/program_options/src/utf8_codecvt_facet.cpp:15: libs/program_options/src/../../detail/utf8_codecvt_facet.cpp:255:7: error: missing binary operator before token "("

The problematic define is in the system wchar.h:
# if defined(_INCLUDE_STDCSOURCE_199901)
# define WCHAR_MAX UINT_MAX /* max value of an unsigned integer */
# define WCHAR_MIN 0
# else
# define WCHAR_MAX (wchar_t)UINT_MAX /* max value of an unsigned integer */
# define WCHAR_MIN (wchar_t)0

# endif

I fixed the problem with a little modification of libs/detail/utf8_codecvt_facet.cpp, I replaced
#if defined(_MSC_VER) && _MSC_VER <= 1310 7.1 or earlier

return 2;

#elif WCHAR_MAX > 0x10000

if (word < 0x10000) {

return 2;

}
if (word < 0x200000) {

return 3;

}
if (word < 0x4000000) {

return 4;

}
return 5;

#else

return 2;

#endif

with this one
#if defined(_MSC_VER) && _MSC_VER <= 1310 7.1 or earlier

return 2;

#else

if (WCHAR_MAX > 0x10000) {

if (word < 0x10000) {

return 2;

}
if (word < 0x200000) {

return 3;

}
if (word < 0x4000000) {

return 4;

}
return 5;

}
else {

return 2;

}

#endif

The comparision WCHAR_MAX > 0x10000 will be done on runtime, and not at compile time, but on runtime the type cast is ok.

Regards,
Vladimir Penev

Change History (6)

comment:1 by Vladimir Prus, 13 years ago

This is compiler bug, I think. Per C standard, 7.18.3/2

Each instance of these macros shall be replaced by a constant expression suitable for use in #if preprocessing directives

It is unclear to me if gcc or HP-UX is at fault, so the best course of action would be to figure who's at fault, figure what is the best resolution (presumably just removing the cast), and then, maybe, applying that resolution inside Boost.Config.

Would you be willing to follow up with gcc/HP-UX folks?

in reply to:  1 comment:2 by anonymous, 13 years ago

Hello Vladimir,

It is unclear to me if gcc or HP-UX is at fault, so the best course of action would be to figure who's at fault, figure what is the best resolution (presumably just removing the cast), and then, maybe, applying that resolution inside Boost.Config.

At my point HP-UX has bad define, and they have change their header according the C standard.

Would you be willing to follow up with gcc/HP-UX folks?

I'm not sure that I would have discussion with, or waiting something from, HP-UX folks...

Regards, Vladimir Penev

comment:3 by Vladimir Prus, 13 years ago

I probably was unclear. This is HP-UX bug, in my opinion. Can you report it to them and see what they have to say, before we do anything further?

in reply to:  3 comment:4 by anonymous, 13 years ago

Replying to vladimir_prus:

I probably was unclear. This is HP-UX bug, in my opinion. Can you report it to them and see what they have to say, before we do anything further?

Sorry, but I can't report it to them, not at this moment ... if you have some way to connect with HP-UX, may be using boost, you will have success in the request.

Regards, Vladimir

comment:5 by Vladimir Prus, 12 years ago

Resolution: wontfix
Status: newclosed

I am not planning to do anything further. It's compiler problem.

comment:6 by James Hugard <james_hugard@…>, 9 years ago

Appears to be a duplicate of Ticket #5048.

Note: See TracTickets for help on using tickets.