Opened 15 years ago

Closed 15 years ago

#1130 closed Bugs (fixed)

GCC -wundef warnings

Reported by: anonymous Owned by: John Maddock
Milestone: Boost 1.35.0 Component: config
Version: Boost 1.34.1 Severity: Problem
Keywords: Cc:

Description

Compiling code that includes Boost headers with gcc -wundef produces a lot of warnings about undefined preprocessor symbols, mainly in BOOST_WORKAROUND(XXX, ...) where XXX is not defined.

Example:

boost/filesystem/fstream.hpp line 103:

#   if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this

should probably be

#   if defined( BOOST_MSVC ) && !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 )

Change History (4)

comment:1 by andyc@…, 15 years ago

I notice that this problem has been discussed previously on <http://lists.boost.org/Archives/boost/2005/10/95850.php> and there's a proposal to do with BoostConfig referenced there: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?BoostConfig>.

I also notice that that's proposing using constructs such as:

Comeau C++ #ifndef BOOST_CXX_COMO #define BOOST_CXX_COMO 0 #endif

I wonder if you could use this instead:

# define BOOST_WORKAROUND(symbol, test) \

((BOOST_COMPILER_DEFINED_ ## symbol) && \

(symbol != 0) && (1 % (( (symbol test) ) + 1)))

and you could then define

#define BOOST_COMPILER_DEFINED_BOOST_MSVC defined(BOOST_MSVC)

for each macro used in a BOOST_WORKAROUND expansion rather than all those #ifndefs. Just a thought. (I also did wonder whether there was some preprocessor magic to save having to define all those by hand but I couldn't come up with any).

Until this problem is resolved in an official boost release, that's what we're intending to do so that we can compile with -Wundef.

-- Andy, BlueArc Engineering

comment:2 by René Rivera, 15 years ago

Component: Noneconfig
Owner: set to John Maddock

comment:3 by John Maddock, 15 years ago

Status: newassigned

I'm working on this now, hopefully we'll work something out!

comment:4 by John Maddock, 15 years ago

Milestone: To Be DeterminedBoost 1.35.0
Resolution: fixed
Status: assignedclosed

This is hopefully now fixed with this changeset: http://svn.boost.org/trac/boost/changeset/39473/trunk/boost/detail/workaround.hpp

Note that the logic we've used is the reverse of yours: the danger with your suggested fix is that if you use BOOST_WORKAROUND with a macro about which it knows nothing, then it will always evaluate to false :-(

Regards, John Maddock.

Note: See TracTickets for help on using tickets.