Re: [Boost-bugs] [Boost C++ Libraries] #2498: #including boost/test/included/unit_test.hpp causes "POLL_ERR is not defined" error when compiling for Linux

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2498: #including boost/test/included/unit_test.hpp causes "POLL_ERR is not defined" error when compiling for Linux
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-11-21 12:49:39


#2498: #including boost/test/included/unit_test.hpp causes "POLL_ERR is not
defined" error when compiling for Linux
----------------------------------------------------+-----------------------
  Reporter: ANDREW CHITTENDEN <andyc@…> | Owner: rogeeff
      Type: Bugs | Status: closed
 Milestone: Boost 1.38.0 | Component: test
   Version: Boost 1.36.0 | Severity: Problem
Resolution: worksforme | Keywords:
----------------------------------------------------+-----------------------

Comment (by Ivo Raisr <ivosh@…>):

 Hi guys,
 I have encountered the same problem with boost 1.47.0.
 My platform is RHEL/CentOS 5.6 with glibc 2.5 and gcc 4.1.2, using -Wundef
 -Werror.

 The problem is still there and lies in fact that POLL_ERR and POLL_HUP are
 declared in system header file "/usr/include/bits/siginfo.h" as follows:

 {{{
 enum
 {
   POLL_IN = 1,
  [....]
   POLL_ERR, /* I/O error. */
 # define POLL_ERR POLL_ERR
   POLL_PRI, /* High priority input available. */
 # define POLL_PRI POLL_PRI
   POLL_HUP /* Device disconnected. */
 # define POLL_HUP POLL_HUP
 };
 }}}

 Please notice that POLL_ERR, POLL_HUP are '''both''' #define's and enum
 values!

 Therefore before preprocessor runs, the line says:
 {{{
 #if defined(POLL_ERR) && defined(POLL_HUP) && (POLL_ERR - POLL_HUP)
 }}}

 Now, POLL_ERR is #define'd, POLL_HUP as well. After preprocessor replaces
 them,
 the line says:
 {{{
 #if (POLL_ERR - POLL_HUP)
 }}}

 But POLL_ERR and POLL_HUP are now enum values, ready to be understood by
 the compiler, not preprocessor. It is not surprise that preprocessor
 cannot substract these two enum values because it does not understand
 them.

 Therefore I conculde this construct is weird and cannot work on any
 platform which:
 - has the same name for both #define and enum value
 - has the same value for both (as this would interfere with the 'default'
 case of the switch)

 Please fix this problem, for example in terms of the original submitted
 patch.
 The test program remains the same:

 {{{
 #define BOOST_TEST_MODULE AnyTest
 #include <boost/test/included/unit_test.hpp>
 }}}

 Should you need more information, just ping me.
 Ivo Raisr

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2498#comment:6>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC