QT5迁移和提升:if.hpp:宏参数不匹配错误 [英] QT5 migration and Boost: if.hpp: Macro argument mismatch bug
问题描述
在QT 4.8我用升压(1.52),这一切都ok了......现在,我尝试移动到QT5并获得 if.hpp:宏参数不匹配
上的错误行 131 BOOST_MPL_AUX_NA_SPEC(3,如果_)
。在某些 QT论坛有presented这样一个解决方案:
的#ifndef Q_MOC_RUN
//所有升压包括
#ENDIF // Q_MOC_RUN
在我的每一个文件,使用升压...所以这里的问题是 - 如何告诉提振了QT还没有准备好 BOOST_MPL_AUX_NA_SPEC
和提升将使用多一些原始preprocessor语法一个会QT5兼容?
更新:发现这一解决方案但似乎没有带来任何效果都在QT5 =(
下面是我已经能够淘净了几个小时后,找到最好的解决方法。这基本上是其他人一直在说,但有一些澄清。
- 的问题与moc.exe做不正确处理升压宏。
- 在为了解决这个问题,我们通过定义包括对moc.exe过程中后卫,但不是经常源代码编译禁止包含升压头。
-
这可以通过添加以下code到项目文件(例如myproject.pro)最容易实现的
#确保QMAKE_MOC包含商务部可执行文件路径
负载(MOC)#每个Boost头文件包括你...
QMAKE_MOC + = -DBOOST_INCLUDE_GUARD_GOES_HERE
例如,如果我想使用的日志库,我有:
的#include<升压/日志/ trivial.hpp>
如果我打开了头文件,我可以在上面看到,包括后卫被命名为 BOOST_LOG_TRIVIAL_HPP_INCLUDED _
。因此,在.pro文件中相应的行内容如下:
QMAKE_MOC + = -DBOOST_LOG_TRIVIAL_HPP_INCLUDED_
如果一对夫妇的更多音符他们相关的人:
- 如果你觉得这不工作,确保运行的qmake和重建项目,只要你添加一个新行到您的项目文件。
- 我使用的Windows 7 32位使用Qt 5.0.1升压1.53和建设中QtCreator MSVC2010。
In qt 4.8 I used boost (1.52) It all was ok... Now I try to move to QT5 and get if.hpp: Macro argument mismatch
error on line 131 BOOST_MPL_AUX_NA_SPEC(3, if_)
. In some QT forums there is presented a solution like this:
#ifndef Q_MOC_RUN
// All boost includes
#endif // Q_MOC_RUN
in each my file that uses boost... So question here is - how to tell to boost that QT is not ready for BOOST_MPL_AUX_NA_SPEC
and that boost shall use some more primitive preprocessor syntax one that would be QT5 compatible?
Update: found this solution yet it seems not to bring any effect at all in Qt5=(
Here is the best workaround I've been able to find after scouring the net for a few hours. It is basically what other folks have been saying, but with a few clarifications.
- The problem has to do with moc.exe not correctly handling Boost macros.
- In order to get around this, we disable inclusion of Boost headers by defining their include guards for the moc.exe process, but not for regular source compilation.
This can be accomplished most easily by adding the following code to your project file (e.g. myproject.pro):
# ensure QMAKE_MOC contains the moc executable path load(moc) # for each Boost header you include... QMAKE_MOC += -DBOOST_INCLUDE_GUARD_GOES_HERE
For example, if I want to use the logging library, I'd have:
#include <boost/log/trivial.hpp>
If I open up the header file, I can see at the top that the include guard is named BOOST_LOG_TRIVIAL_HPP_INCLUDED_
. Therefore, the corresponding line in the .pro file would read:
QMAKE_MOC += -DBOOST_LOG_TRIVIAL_HPP_INCLUDED_
A couple of more notes in case they are relevant for anyone:
- If you find this not working, make sure to run qmake and rebuild your project whenever you add a new line to your project file.
- I'm using Boost 1.53 with Qt 5.0.1 and building for MSVC2010 within QtCreator on Windows 7 32-bit.
这篇关于QT5迁移和提升:if.hpp:宏参数不匹配错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!