Opened 14 years ago

Closed 13 years ago

Last modified 11 years ago

#2498 closed Bugs (worksforme)

#including boost/test/included/unit_test.hpp causes "POLL_ERR is not defined" error when compiling for Linux

Reported by: ANDREW CHITTENDEN <andyc@…> Owned by: Gennadiy Rozental
Milestone: Boost 1.38.0 Component: test
Version: Boost 1.36.0 Severity: Problem
Keywords: Cc:

Description

This happens on boost 1_37_0.

When compiling this simple program:

#include <boost/test/included/unit_test.hpp>

gives these errors when compiled with "gcc -W -Wall -Wundef"

In file included from /home/andyc/work/3rdParty/boost_1_37_0/boost/test/included/unit_test.hpp:22,

from test.cpp:1:

/home/andyc/work/3rdParty/boost_1_37_0/boost/test/impl/execution_monitor.ipp:480:48: warning: "POLL_ERR" is not defined /home/andyc/work/3rdParty/boost_1_37_0/boost/test/impl/execution_monitor.ipp:480:59: warning: "POLL_HUP" is not defined In file included from /home/andyc/work/3rdParty/boost_1_37_0/boost/test/output/compiler_log_formatter.hpp:20,

from /home/andyc/work/3rdParty/boost_1_37_0/boost/test/impl/compiler_log_formatter.ipp:19, from /home/andyc/work/3rdParty/boost_1_37_0/boost/test/included/unit_test.hpp:18, from test.cpp:1:

/home/andyc/work/3rdParty/boost_1_37_0/boost/test/utils/basic_cstring/basic_cstring.hpp: In instantiation of ?boost::unit_test::basic_cstring<const char>?: /home/andyc/work/3rdParty/boost_1_37_0/boost/test/unit_test_log_formatter.hpp:63: instantiated from here /home/andyc/work/3rdParty/boost_1_37_0/boost/test/utils/basic_cstring/basic_cstring.hpp:209: warning: type qualifiers ignored on function return type /home/andyc/work/3rdParty/boost_1_37_0/boost/test/utils/basic_cstring/basic_cstring.hpp:218: warning: type qualifiers ignored on function return type In file included from /home/andyc/work/3rdParty/boost_1_37_0/boost/test/included/unit_test.hpp:22,

from test.cpp:1:

/home/andyc/work/3rdParty/boost_1_37_0/boost/test/impl/execution_monitor.ipp: In destructor ?boost::detail::signal_handler::~signal_handler()?: /home/andyc/work/3rdParty/boost_1_37_0/boost/test/impl/execution_monitor.ipp:678: warning: missing initializer for member ?sigaltstack::ss_sp? /home/andyc/work/3rdParty/boost_1_37_0/boost/test/impl/execution_monitor.ipp:678: warning: missing initializer for member ?sigaltstack::ss_flags? /home/andyc/work/3rdParty/boost_1_37_0/boost/test/impl/execution_monitor.ipp:678: warning: missing initializer for member ?sigaltstack::ss_size? In file included from /home/andyc/work/3rdParty/boost_1_37_0/boost/test/included/unit_test.hpp:31,

from test.cpp:1:

/home/andyc/work/3rdParty/boost_1_37_0/boost/test/utils/basic_cstring/basic_cstring.hpp: In constructor ?boost::unit_test::test_case_filter::single_filter::single_filter(boost::unit_test::const_string)?: /home/andyc/work/3rdParty/boost_1_37_0/boost/test/utils/basic_cstring/basic_cstring.hpp:686: warning: type qualifiers ignored on function return type /home/andyc/work/3rdParty/boost_1_37_0/boost/test/utils/basic_cstring/basic_cstring.hpp:701: warning: type qualifiers ignored on function return type

Attachments (1)

2498.patch (2.1 KB ) - added by ANDREW CHITTENDEN <andyc@…> 14 years ago.
attached patch clears up the error.

Download all attachments as: .zip

Change History (7)

by ANDREW CHITTENDEN <andyc@…>, 14 years ago

Attachment: 2498.patch added

attached patch clears up the error.

comment:1 by Marshall Clow, 14 years ago

Component: Nonetest
Owner: set to Gennadiy Rozental

comment:2 by Gennadiy Rozental, 14 years ago

what the OS/compiler

comment:3 by ANDREW CHITTENDEN <andyc@…>, 14 years ago

what the OS ...

Linux (as per subject of the bug). In particular, this is a debian system running 2.6.26 with glibc 2.7.

compiler

gcc 4.3.2.

NB as I said initially, this happens on boost 1_37_0 - that wasn't available on the pull down when I submitted the bug. I don't know whether it happens on 1_36_0.

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

Resolution: worksforme
Status: newclosed

Replying to ANDREW CHITTENDEN <andyc@bluearc.com>:

what the OS ...

Linux (as per subject of the bug). In particular, this is a debian system running 2.6.26 with glibc 2.7.

compiler

gcc 4.3.2.

I've tried to replicate the issue on debian vmware image with this parameters:

rogeeff@debian:~/boost/libs/test/example$ uname -a Linux debian 2.6.8-2-386 #1 Thu May 19 17:40:50 JST 2005 i686 GNU/Linux

gcc version 4.3.2 (Debian 4.3.2-1.1)

and it works fine.

Please let me know how to reproduce it and reopen the ticket

comment:5 by Gennadiy Rozental, 13 years ago

P.S. I was using trunk

comment:6 by Ivo Raisr <ivosh@…>, 11 years ago

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

Note: See TracTickets for help on using tickets.