Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#6455 closed Feature Requests (fixed)

Boost foreach conflicts with Q_FOREACH and moc generation.

Reported by: Chuck Lloyd <chuck.lloyd@…> Owned by: Eric Niebler
Milestone: To Be Determined Component: foreach
Version: Boost 1.48.0 Severity: Problem
Keywords: Qt foreach Cc: smr@…

Description

The change to fix Ticket #6131 caused a latent bug to manifest in the interaction with the Qt header qglobal.h.

The header replaces all instances of foreach with Q_FOREACH. In version 1.47 this replacement was consistent. In version 1.48 the move of is_lightweight_proxy<T> and is_noncopyable<T> to the BOOST_FOREACH namespace causes errors:

c:\boost\alg_1_48_0_64\boost\foreach.hpp(169): error C2039: 'tag' : is not a member of 'boost::Q_FOREACH' c:\boost\alg_1_48_0_64\boost\foreach.hpp(169): error C2061: syntax error : identifier 'tag'

A workaround is to turn off this substitution by defining QT_NO_KEYWORDS.

This will also require replacing all keywords signals and slots with Q_SIGNALS and Q_SLOTS.

It would be nice if these libs could co-exist.

Attachments (2)

boost_foreach_qt_error_example.cpp (1.3 KB ) - added by alex@… 8 years ago.
A test case for boost foreach's interplay with qt's foreach keyword
boost_foreach_error_output.txt (49.9 KB ) - added by alex@… 8 years ago.
Error output for the attached testcase for OSX 10.9 against boost 1.55.0

Download all attachments as: .zip

Change History (8)

comment:1 by smr@…, 11 years ago

Cc: smr@… added

comment:2 by Eric Niebler, 11 years ago

Status: newassigned

Thanks. It seems the fix to #6131 is doing more harm than good. It's been reverted on trunk, and will be merged to release as soon as the tests cycle. Thanks.

comment:3 by Eric Niebler, 11 years ago

Resolution: fixed
Status: assignedclosed

(In [77591]) merge [77416] from trunk, fixes #6131, fixes #6455

comment:4 by bekveron@…, 9 years ago

I'm having the same problem with boost 1.54.0 and Qt. Thought the issue has been fixed. So the libs are still incompatible? Do you recommend to use this workaround with QT_NO_KEYWORDS?

comment:5 by alex@…, 8 years ago

Hi,

I'm still having issues with <boost/foreach.hpp> and Qt's foreach with various recent versions of boost (checked that the issue is present in 1.50.0 and 1.55.0). I will attach a single-file test case which demonstrates the issue where the application fails to compile with the BOOST_FOREACH construct present in a Qt application. The number and order of include files appears to be key, if you cut it down to just the core application and the <boost/foreach.hpp> include then the error is gone, so there's some interplay going on here. I'll also attach the errors I get when compiling on this platform (OSX 10.9 against boost 1.55.0, clang x86_64).

by alex@…, 8 years ago

A test case for boost foreach's interplay with qt's foreach keyword

by alex@…, 8 years ago

Error output for the attached testcase for OSX 10.9 against boost 1.55.0

comment:6 by alex@…, 8 years ago

Oh my word that's so embarrassing, I had the wrong tab open in the build preferences, I am getting an error as the output shows, but my test-case still isn't working to show it. I'll work on getting it right and come back to you. If an admin wants to clean this up feel free.

Note: See TracTickets for help on using tickets.