#6455 closed Feature Requests (fixed)
Boost foreach conflicts with Q_FOREACH and moc generation.
Reported by: | 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)
Change History (8)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 11 years ago
Status: | new → assigned |
---|
comment:3 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:4 by , 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 , 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 , 8 years ago
Attachment: | boost_foreach_qt_error_example.cpp added |
---|
A test case for boost foreach's interplay with qt's foreach keyword
by , 8 years ago
Attachment: | boost_foreach_error_output.txt added |
---|
Error output for the attached testcase for OSX 10.9 against boost 1.55.0
comment:6 by , 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.
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.