1 Attachment(s)
Hiding boost headers from MOC, but still error
I've made fresh install of Qt 5.1.0 on Windows 7. I'm trying to compile my project which is using boost library interprocess communication. Since it was giving compilation error earlier, I've made the moc not to detect boost headers by adding #ifndef Q_MOC_RUN & #endif between the boost headers. It worked fine then.
Now had to change my PC, installed fresh copy of Windows 7, then installed Qt 5.1.0 MSVC 2010. After building the project the same error which used occur earlier for not adding #ifndef Q_MOC_RUN surfaced again. But now I'm adding that around boost headers.
Code:
D:\boost_1_53_0\boost\mpl\if.hpp:131: error: Macro argument mismatch.
And on clicking the reported issue - the code it pointed is
Code:
// if.hpp
struct if_
{
enum { msvc_wknd_ = BOOST_MPL_AUX_MSVC_VALUE_WKND(C_)::value };
typedef typename aux::if_impl< BOOST_MPL_AUX_STATIC_CAST(bool, msvc_wknd_) >
::template result_<T1,T2>::type type;
BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C_,T1,T2))
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
BOOST_MPL_AUX_NA_SPEC(3, if_) // <<------------------- Here
}}
Someone please help me. It's affecting my tight schedule by not allowing me to proceed further.
And my project settings looks like as shown in the attached pic.
Attachment 9280
Thank you.
Re: Hiding boost headers from MOC, but still error
I am assuming that moc is producing that message when faced with your source code. The specified Boost 1.53 include, for example, runs through Qt 5.1.0 moc without error and without special measures (and later compiles without error):
Code:
#include <QCoreApplication>
#include <boost/mpl/if.hpp>
{
Q_OBJECT
public:
signals:
void stuff();
};
int main(int argc, char **argv)
{
return 0;
}
#include "main.moc"
So, the question becomes, what else are you including and in what order.
Did you build you own Qt with the MSVC 2010 compiler? If so, did you install the required Microsoft patches in the required order first?
Re: Hiding boost headers from MOC, but still error
I've not included #include <boost/mpl/if.hpp>
The headers I included are
Code:
#ifndef Q_MOC_RUN
#include <boost/interprocess/managed_windows_shared_memory.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/containers/string.hpp>
#endif // Q_MOC_RUN
using namespace boost::interprocess;
// Types
typedef managed_shared_memory::segment_manager segment_manager_t;
typedef boost::interprocess::allocator<void, segment_manager_t> void_allocator;
typedef boost::interprocess::allocator<char, segment_manager_t> char_allocator;
typedef boost::interprocess::basic_string<char, std::char_traits<char>, char_allocator> char_string;
typedef std::pair<const size_t, char_string> size_t_string_map_value_type;
typedef std::pair<size_t, char_string> movable_to_size_t_string_map_value_type;
typedef boost::interprocess::allocator<size_t_string_map_value_type, segment_manager_t> size_t_string_map_value_type_allocator;
typedef boost::interprocess::map<size_t, char_string, std::less<size_t>, size_t_string_map_value_type_allocator> size_t_string_map_type;
typedef std::pair<const char_string, char_string> string_string_map_value_type;
typedef std::pair<char_string, char_string> movable_to_string_string_map_value_type;
typedef boost::interprocess::allocator<string_string_map_value_type, segment_manager_t> string_string_map_value_type_allocator;
typedef boost::interprocess::map<char_string, char_string, std::less<char_string>, string_string_map_value_type_allocator> string_string_map_type;
typedef std::pair<const char_string, bool> string_bool_map_value_type;
typedef std::pair<char_string, bool> movable_to_string_bool_map_value_type;
typedef boost::interprocess::allocator<string_bool_map_value_type, segment_manager_t> string_bool_map_value_type_allocator;
typedef boost::interprocess::map<char_string, bool, std::less<char_string>, string_bool_map_value_type_allocator> string_bool_map_type;
{
Q_OBJECT
// my class members
};
Quote:
Did you build you own Qt with the MSVC 2010 compiler?
No, I've downloaded qt-windows-opensource-5.1.0-msvc2010-x86-offline.exe. Later installed Windows SDK, to get MSVC 2010 compiler.
In this link someone posted same problem and mentioned 4.8.4 is not having this problem. If Qt 4.8 does not have any issues, then are there any dependencies to go back from Qt 5.0.2/5.1 ??
Thank you.
Re: Hiding boost headers from MOC, but still error
You have included if.hpp indirectly... that is where the error is being reported. It may be triggered by something processed before that.
The header Tannin was having problems with in the thread you linked also passes moc cleanly in its 1.53 incarnation.
Your collection of headers and typedefs run through moc cleanly when dropped into my test code above.
I used the official 5.1 MingW build but since you are not getting as far as the compiler the MingW vs MSVC difference is irrelevant.
I suggest you check that you are running qmake/moc from the Qt version you think you are.
If you want to go back to Qt 4.8.5 then there may be changes you need to make to your source. Unfortunately my crystal ball is away for servicing.
2 Attachment(s)
Re: Hiding boost headers from MOC, but still error
Let me in explain steps what I've done, pls help me with this.
1. Installed a Windows 7 freshly on my machine
2. Then installed .NET 4 Framework
3. Then installed Windows SDK 7.1 with all the options checked
4. Installed Qt 5.0.2 MSVC 2010 x86
5. Downloaded boost 1.53 & got libboost_date_time-vc100-mt-1_53.lib & libboost_date_time-vc100-mt-gd-1_53.lib from my peer who compiled the same. Using only date_time because I'm using boost shared memory only.
6. Added "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin" to system environment variables path. Don't know if I have to do this, but just added to make sure that cl.exe is in environment variables path.
7. Compiling project gives D:\boost_1_53_0\boost\mpl\if.hpp:131: error: Macro argument mismatch.
My .pro file is
Code:
QT += core gui network xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = BrainyAssUI
TEMPLATE = app
SOURCES += main.cpp\
.. source files
HEADERS += ... headerfiles
RESOURCES += \
addons.qrc
INCLUDEPATH += D:/boost_1_53_0\
D:/svn/UtilityParser/include\
D:/svn/vtd-xml
QMAKE_CXXFLAGS += /FI"customTypes.h"
QMAKE_CXXFLAGS += /DNOMINMAX
LIBS += -L"D:/boost_lib"\
-llibboost_date_time-vc100-mt-1_53
-lole32\
-loleaut32\
-L"D:/svn/UtilityParser/Release"\
-lUtilityParser\
-lvtd-xml
My boost lib files are in D:\boost_lib
And boost include folder is D:\boost_1_53_0
Added #ifndef Q_MOC_RUN to the boost headers to hide from MOC
Code:
#ifndef Q_MOC_RUN
#include <boost/mpl/if.hpp>
#include <boost/interprocess/managed_windows_shared_memory.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/containers/string.hpp>
#endif // Q_MOC_RUN
So finally the error I get - D:\boost_1_53_0\boost\mpl\if.hpp:131: error: Macro argument mismatch.
Kindly help me tackle this issue.
Adding more info (this is not directly related to Qt, but boost. Still explaining it as this might give more insight into my problem help you understand where I'm doing wrong.)
Tried to compile boost using command line option that comes with Qt 5.0.2 MSVC 2010. When I try to build boost (run bootstrap.bat \tools\v2\) it says -
Code:
cl.exe - System Error
The program can't start because mspdb100.dll is missing from your computer. Try reinstalling the program to fix this problem.
Screenshot of my Tools > Options > Build & Run > Compilers
Attachment 9302
Screenshot of my installed programs (this might give clear picture if I've installed required tools to build my project)
Attachment 9303
Re: Hiding boost headers from MOC, but still error
Put this code in a file main.cpp:
Code:
#include <QCoreApplication>
// Begin: Your headers exactly as given to us
#ifndef Q_MOC_RUN
#include <boost/interprocess/managed_windows_shared_memory.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/containers/string.hpp>
#endif // Q_MOC_RUN
using namespace boost::interprocess;
// Types
typedef managed_shared_memory::segment_manager segment_manager_t;
typedef boost::interprocess::allocator<void, segment_manager_t> void_allocator;
typedef boost::interprocess::allocator<char, segment_manager_t> char_allocator;
typedef boost::interprocess::basic_string<char, std::char_traits<char>, char_allocator> char_string;
typedef std::pair<const size_t, char_string> size_t_string_map_value_type;
typedef std::pair<size_t, char_string> movable_to_size_t_string_map_value_type;
typedef boost::interprocess::allocator<size_t_string_map_value_type, segment_manager_t> size_t_string_map_value_type_allocator;
typedef boost::interprocess::map<size_t, char_string, std::less<size_t>, size_t_string_map_value_type_allocator> size_t_string_map_type;
typedef std::pair<const char_string, char_string> string_string_map_value_type;
typedef std::pair<char_string, char_string> movable_to_string_string_map_value_type;
typedef boost::interprocess::allocator<string_string_map_value_type, segment_manager_t> string_string_map_value_type_allocator;
typedef boost::interprocess::map<char_string, char_string, std::less<char_string>, string_string_map_value_type_allocator> string_string_map_type;
typedef std::pair<const char_string, bool> string_bool_map_value_type;
typedef std::pair<char_string, bool> movable_to_string_bool_map_value_type;
typedef boost::interprocess::allocator<string_bool_map_value_type, segment_manager_t> string_bool_map_value_type_allocator;
typedef boost::interprocess::map<char_string, bool, std::less<char_string>, string_bool_map_value_type_allocator> string_bool_map_type;
{
Q_OBJECT
// my class members
};
// End: Your headers exactly as given to us
int main(int argc, char **argv)
{
return 0;
}
#include "main.moc"
with this project file:
Code:
######################################################################
# Automatically generated by qmake (3.0) Thu Jul 18 14:08:58 2013
######################################################################
TEMPLATE = app
TARGET = test
INCLUDEPATH += "D:/boost_1_53_0"
# Input
SOURCES += main.cpp
Does it compile cleanly? If so then the problem is elsewhere, possibly in the customTypes.h header you are force-including into every single file rather than doing it explicitly where it's needed (i.e. properly).
Re: Hiding boost headers from MOC, but still error
Thank you very much ChrisW67. I was including a header for the dll which I didn't know that it was using boost. Pushing that include into #ifndef Q_MOC solved the problem.
Quote:
Does it compile cleanly? If so then the problem is elsewhere, ..
The code which you posted above compiled cleanly and your answer made me re look at the libraries & check if they are using boost.
Thank you very much.