更新时间:2023-10-23 10:03:28
下面是我已经能够淘净了几个小时后,找到***的解决方法。这基本上是其他人一直在说,但有一些澄清。
这可以通过添加以下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_
如果一对夫妇的更多音符他们相关的人:
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.
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: