I have an application that requires use of both Qt 3D and the QCustomPlot library. However, when attempting to compile QCustomPlot in a project using "QT += 3dinput" in its .pro file, several errors appear referencing the QMouseEvent and QWheelEvent classes.
I believe this is related to the fact that Qt3DInput introduces classes with the same names as QMouseEvent and QWheelEvent in the QtGui module, but am not familiar enough with the inner workings of Qt to understand what the compiler errors are trying to tell me.
What exactly is causing this issue, and how can I work around it? Modifications to the .pro file or the QCustomPlot library itself are both acceptable.
To demonstrate the problem, compiling QCustomPlot with the following .pro file:
QT += widgets printsupport 3dinput
TEMPLATE = lib
SOURCES += qcustomplot.cpp
HEADERS += qcustomplot.h
Results in these errors:
In file included from C:/Qt/5.7/mingw53_32/include/QtCore/qnamespace.h:43:0,
from C:/Qt/5.7/mingw53_32/include/QtCore/qobjectdefs.h:48,
from C:/Qt/5.7/mingw53_32/include/QtCore/qobject.h:46,
from C:/Qt/5.7/mingw53_32/include/QtCore/QObject:1,
from debug\../../QCustomPlot/qcustomplot.h:29,
from debug\moc_qcustomplot.cpp:9:
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h: In instantiation of 'constexpr int qMetaTypeId() [with T = QMouseEvent*]':
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1752:26: required from 'constexpr int qRegisterMetaType() [with T = QMouseEvent*]'
debug\moc_qcustomplot.cpp:2512:84: required from here
C:/Qt/5.7/mingw53_32/include/QtCore/qglobal.h:746:47: error: static assertion failed: Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system
#define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
^
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1745:5: note: in expansion of macro 'Q_STATIC_ASSERT_X'
Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
^
In file included from C:/Qt/5.7/mingw53_32/include/QtCore/qobject.h:54:0,
from C:/Qt/5.7/mingw53_32/include/QtCore/QObject:1,
from debug\../../QCustomPlot/qcustomplot.h:29,
from debug\moc_qcustomplot.cpp:9:
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h: In instantiation of 'static constexpr int QMetaTypeId2<T>::qt_metatype_id() [with T = QMouseEvent*]':
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1746:43: required from 'constexpr int qMetaTypeId() [with T = QMouseEvent*]'
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1752:26: required from 'constexpr int qRegisterMetaType() [with T = QMouseEvent*]'
debug\moc_qcustomplot.cpp:2512:84: required from here
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1604:96: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<QMouseEvent*>'
static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
^
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1604:100: error: body of constexpr function 'static constexpr int QMetaTypeId2<T>::qt_metatype_id() [with T = QMouseEvent*]' not a return-statement
static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
^
In file included from C:/Qt/5.7/mingw53_32/include/QtCore/qnamespace.h:43:0,
from C:/Qt/5.7/mingw53_32/include/QtCore/qobjectdefs.h:48,
from C:/Qt/5.7/mingw53_32/include/QtCore/qobject.h:46,
from C:/Qt/5.7/mingw53_32/include/QtCore/QObject:1,
from debug\../../QCustomPlot/qcustomplot.h:29,
from debug\moc_qcustomplot.cpp:9:
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h: In instantiation of 'constexpr int qMetaTypeId() [with T = QWheelEvent*]':
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1752:26: required from 'constexpr int qRegisterMetaType() [with T = QWheelEvent*]'
debug\moc_qcustomplot.cpp:2540:84: required from here
C:/Qt/5.7/mingw53_32/include/QtCore/qglobal.h:746:47: error: static assertion failed: Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system
#define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
^
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1745:5: note: in expansion of macro 'Q_STATIC_ASSERT_X'
Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use the Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system");
^
In file included from C:/Qt/5.7/mingw53_32/include/QtCore/qobject.h:54:0,
from C:/Qt/5.7/mingw53_32/include/QtCore/QObject:1,
from debug\../../QCustomPlot/qcustomplot.h:29,
from debug\moc_qcustomplot.cpp:9:
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h: In instantiation of 'static constexpr int QMetaTypeId2<T>::qt_metatype_id() [with T = QWheelEvent*]':
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1746:43: required from 'constexpr int qMetaTypeId() [with T = QWheelEvent*]'
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1752:26: required from 'constexpr int qRegisterMetaType() [with T = QWheelEvent*]'
debug\moc_qcustomplot.cpp:2540:84: required from here
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1604:96: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<QWheelEvent*>'
static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
^
C:/Qt/5.7/mingw53_32/include/QtCore/qmetatype.h:1604:100: error: body of constexpr function 'static constexpr int QMetaTypeId2<T>::qt_metatype_id() [with T = QWheelEvent*]' not a return-statement
static inline Q_DECL_CONSTEXPR int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
^
This was obviously using MinGW, but VC++ produces similar errors.
Related
I defined a map like this :
std::map<std::string,LexType> lexname_s = { { "PROGRAM" , PROGRAM}}
And a LexType, like this :
typedef enum
{
ENDFILE, ERROR,
PROGRAM, PROCEDURE, TYPE, VAR, IF,
} LexType;
In Visual Studio Code, it always shows error type when I touch it.
//
I add more details for what i said.
the line
std::map<std::string,LexType> lexname_s = { { "PROGRAM" , PROGRAM}}
show error . it seems i can't initialize it in this way.
I compile it in the gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) in a cloud server which is centos7.
AND the error code shows below
from parse.cpp:1:
../utils.h:52:27: error: invalid conversion from ‘int’ to ‘const LexType&’ [-fpermissive]
{"ERROR", ERROR}};
^
In file included from /usr/include/c++/4.8.2/bits/stl_algobase.h:64:0,
from /usr/include/c++/4.8.2/bits/stl_tree.h:61,
from /usr/include/c++/4.8.2/map:60,
from ../globals.h:6,
from parse.h:4,
from parse.cpp:1:
/usr/include/c++/4.8.2/bits/stl_pair.h:112:26: error: initializing argument 2 of ‘constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = const std::basic_string<char>; _T2 = LexType]’ [-fpermissive]
_GLIBCXX_CONSTEXPR pair(const _T1& __a, const _T2& __b)```
EOF(which shows in the map define) is a reserved a macro defined in stdio.h
it's the problem of it.
change the name will be ok.
I've got lots of bugs in my old compilation machine so I decided to create a new one.
Boh project doesn't have any issue about compiling in BOOST 1.55, but in 1.5.7 or highter, only one project can compile. (Before, both are using boost 1.5.7 without problem)
Here's the bug when i'm using 1.5.8 (at char_skill.cpp)
http://i.stack.imgur.com/sh8vO.png
Text mode :
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:193:24: note: template argument deduction/substitution failed:
In file included from /usr/src/blabla/Extern/include/boost/functional/hash/hash.hpp:558:0,
from /usr/src/blabla/Extern/include/boost/functional/hash.hpp:6,
from /usr/src/blabla/Extern/include/boost/unordered/unordered_map.hpp:21,
from /usr/src/blabla/Extern/include/boost/unordered_map.hpp:17,
from char.h:4,
from char_skill.cpp:7:
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:262:34: note: 'const VID' is not derived from 'const std::shared_ptr<_Tp1>'
return hash_value(val);
^
In file included from /usr/src/blabla/Extern/include/boost/functional/hash/hash.hpp:558:0,
from /usr/src/blabla/Extern/include/boost/functional/hash.hpp:6,
from /usr/src/blabla/Extern/include/boost/unordered/unordered_map.hpp:21,
from /usr/src/blabla/Extern/include/boost/unordered_map.hpp:17,
from char.h:4,
from char_skill.cpp:7:
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:198:24: note: template<class T, class Deleter> std::size_t boost::hash_value(const std::unique_ptr<_Tp, _Dp>&)
inline std::size_t hash_value(std::unique_ptr<T, Deleter> const& x) {
^
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:198:24: note: template argument deduction/substitution failed:
In file included from /usr/src/blabla/Extern/include/boost/functional/hash/hash.hpp:558:0,
from /usr/src/blabla/Extern/include/boost/functional/hash.hpp:6,
from /usr/src/blabla/Extern/include/boost/unordered/unordered_map.hpp:21,
from /usr/src/blabla/Extern/include/boost/unordered_map.hpp:17,
from char.h:4,
from char_skill.cpp:7:
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:262:34: note: 'const VID' is not derived from 'const std::unique_ptr<_Tp, _Dp>'
return hash_value(val);
^
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp: In member function 'std::size_t boost::hash<T>::operator()(const T&) const [with T = VID; std::size_t = unsigned int]':
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:263:9: warning: control reaches end of non-void function [-Wreturn-type]
}
^
gmake: *** [OBJDIR/char_skill.o] Error 1
I don't know why I have this problem :x
PS : If anyone know how to install boost-all (1.5.7 or +) using freebsd ^^
Have a nice day :)
I'm trying to compile my legacy-free libFoundation project, located at https://github.com/chmeeedalf/lf-foundation but running into problems using clang 3.4 and libc++. It appears something is not happy with ARC in the containers, and I see the following error excerpt:
In file included from /home/chmeee/git-lffoundation/src/Collections/NSCoreArray.mm:34:
In file included from /home/chmeee/git-lffoundation/src/../Headers/Foundation/NSArray.h:31:
In file included from /home/chmeee/git-lffoundation/src/../Headers/Foundation/NSObject.h:40:
In file included from /home/chmeee/git-lffoundation/src/../Headers/Foundation/NSRange.h:192:
In file included from /usr/include/c++/v1/algorithm:627:
/usr/include/c++/v1/memory:913:17: error: call to 'addressof' is ambiguous
{return _VSTD::addressof(__r);}
^~~~~~~~~~~~~~~~
/usr/include/c++/v1/__config:341:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
^
/usr/include/c++/v1/vector:1678:65: note: in instantiation of member function 'std::__1::pointer_traits<const __strong id *>::pointer_to' requested here
const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
^
/home/chmeee/git-lffoundation/src/Collections/NSCoreArray.mm:115:8: note: in instantiation of member function 'std::__1::vector<id, std::__1::allocator<id> >::insert' requested here
items.insert(items.begin() + index, anObject);
^
/usr/include/c++/v1/__functional_base:96:1: note: candidate function [with _Tp = const id]
addressof(__strong _Tp& __x) _NOEXCEPT
^
/usr/include/c++/v1/__functional_base:122:1: note: candidate function [with _Tp = const id]
addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
^
/usr/include/c++/v1/__functional_base:83:1: note: candidate function [with _Tp = const id]
addressof(_Tp& __x) _NOEXCEPT
^
1 error generated.
*** Error code 1
Stop.
make: stopped in /home/chmeee/git-lffoundation/src
Exit 1
The file in this example has a std::vector declared as:
std::vector<id> items;
Can someone shed some light onto this problem? I tried adding an explicit __strong in the std::vector declaration, to no avail, however __unsafe_unretained does eliminate the error.
I'm building on FreeBSD -CURRENT, using the libc++ and clang 3.4 that is in base.
Answering my own question, in case others are interested. Clang defines __weak as a preprocessor macro for ARC. However, FreeBSD's <sys/cdefs.h> also defines __weak itself. The workaround I found for this was to add to my local <sys/cdefs.h>:
#ifndef __weak
#define __weak what_freebsd_defines_ass
#endif
I'm trying something simple with threads and mutexes in C++ with boost.
This is the code:
#include <iostream>
#include <boost/thread/thread.hpp>
class mutex_test
{
private:
boost::mutex mut;
public:
void operator()()
{
boost::mutex::scoped_lock lock(mut);
std::cout << "Hi!" << std::endl;
}
};
int main()
{
mutex_test tester;
boost::thread tester_thread(tester);
tester_thread.join();
return 0;
}
On compile, I get this error:
In file included from C:\boost/boost/thread/detail/thread.hpp:15:0,
from C:\boost/boost/thread/thread.hpp:22,
from main.cpp:3:
C:\boost/boost/thread/detail/move.hpp: In instantiation of 'typename boost::decay<T>::type boost::thread_detail::decay_copy(T&&) [with T = mutex_test&; typename boost::decay<T>::type = mutex_test]':
C:\boost/boost/thread/detail/thread.hpp:265:88: required from 'boost::thread::thread(F&&) [with F = mutex_test&]'
main.cpp:20:36: required from here
C:\boost/boost/thread/detail/move.hpp:246:37: error: use of deleted function 'mutex_test::mutex_test(const mutex_test&)'
main.cpp:5:7: note: 'mutex_test::mutex_test(const mutex_test&)' is implicitly deleted because the default definition would be ill-formed:
main.cpp:5:7: error: use of deleted function 'boost::mutex::mutex(const boost::mutex&)'
In file included from C:\boost/boost/thread/mutex.hpp:14:0,
from C:\boost/boost/thread/detail/thread.hpp:16,
from C:\boost/boost/thread/thread.hpp:22,
from main.cpp:3:
C:\boost/boost/thread/win32/mutex.hpp:29:9: error: declared here
In file included from C:\boost/boost/thread/thread.hpp:22:0,
from main.cpp:3:
C:\boost/boost/thread/detail/thread.hpp: In instantiation of 'boost::detail::thread_data<F>::thread_data(F&&) [with F = mutex_test]':
C:\boost/boost/thread/win32/thread_heap_alloc.hpp:100:72: required from 'T* boost::detail::heap_new(A1&&) [with T = boost::detail::thread_data<mutex_test>; A1 = mutex_test]'
C:\boost/boost/thread/detail/thread.hpp:214:38: required from 'static boost::detail::thread_data_ptr boost::thread::make_thread_info(F&&) [with F = mutex_test; boost::detail::thread_data_ptr = boost::intrusive_ptr<boost::detail::thread_data_base>]'
C:\boost/boost/thread/detail/thread.hpp:265:88: required from 'boost::thread::thread(F&&) [with F = mutex_test&]'
main.cpp:20:36: required from here
C:\boost/boost/thread/detail/thread.hpp:98:40: error: use of deleted function 'mutex_test::mutex_test(const mutex_test&)'
In file included from C:\boost/boost/system/system_error.hpp:14:0,
from C:\boost/boost/thread/exceptions.hpp:22,
from C:\boost/boost/thread/win32/thread_primitives.hpp:16,
from C:\boost/boost/thread/win32/thread_data.hpp:11,
from C:\boost/boost/thread/thread.hpp:15,
from main.cpp:3:
C:\boost/boost/system/error_code.hpp:214:36: warning: 'boost::system::posix_category' defined but not used [-Wunused-variable]
C:\boost/boost/system/error_code.hpp:215:36: warning: 'boost::system::errno_ecat' defined but not used [-Wunused-variable]
C:\boost/boost/system/error_code.hpp:216:36: warning: 'boost::system::native_ecat' defined but not used [-Wunused-variable]
Makefile:21: recipe for target 'main.o' failed
The error only occurs when I try to create a thread for the functor; executing it straight works fine.
Additionally, if I remove all references to mutexes and locks it works fine.
E: Had the wrong error log. Whoops.
boost::mutex is not a copyable or moveable (using boost's move implementation) type, and hence, passing it in that way to the thread will not work, since that constructor makes a copy of the functor to execute on the thread.
In your test case, you would want to use the following
boost::thread tester_thread(boost::ref(functor))
This passes it by reference, instead of by copy. Note, this also requires that the functor remain valid until the thread exits. Since you're joining the thread, that's the case here, but more complicated cases that might not be true.
I need to (de)serialize data on both Windows and Linux (and transfer the files in between). I wanted to use the portable binary archives of Boost's serialization library which can be found in the examples, see e.g. at http://boost-doc-zh.googlecode.com/svn-history/r380/trunk/libs/serialization/example/
This works fine on Windows (VS 2008) but fails to compile under GCC 4.3.2 with the following errors.
Can anybody suggest a solution?
Thanks a lot!
/projects/lib/BOOST/1_44_0/include/boost/archive/basic_archive.hpp: In member function 'void portable_binary_iarchive::init(unsigned int)':
/projects/lib/BOOST/1_44_0/include/boost/archive/basic_archive.hpp:78: error: 'uint_least32_t boost::archive::version_type::t' is private
/home/myfolder/src/portable_binary_iarchive.cpp:92: error: within this context
/home/myfolder/src/portable_binary_iarchive.hpp: In member function 'void portable_binary_iarchive::load(T&) [with T = boost::archive::class_id_type]':
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/iserializer.hpp:107: instantiated from 'static void boost::archive::load_access::load_primitive(Archive&, T&) [with Archive = portable_binary_iarchive, T = boost::archive::class_id_type]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/iserializer.hpp:356: instantiated from 'static void boost::archive::detail::load_non_pointer_type<Archive>::load_primitive::invoke(Archive&, T&) [with T = boost::archive::class_id_type, Archive = portable_binary_iarchive]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/iserializer.hpp:433: instantiated from 'static void boost::archive::detail::load_non_pointer_type<Archive>::invoke(Archive&, T&) [with T = boost::archive::class_id_type, Archive = portable_binary_iarchive]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/iserializer.hpp:586: instantiated from 'void boost::archive::load(Archive&, T&) [with Archive = portable_binary_iarchive, T = boost::archive::class_id_type]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/common_iarchive.hpp:66: instantiated from 'void boost::archive::detail::common_iarchive<Archive>::load_override(T&, int) [with T = boost::archive::class_id_type, Archive = portable_binary_iarchive]'
/home/myfolder/src/portable_binary_iarchive.hpp:140: instantiated from 'void portable_binary_iarchive::load_override(T&, int) [with T = boost::archive::class_id_type]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/interface_iarchive.hpp:60: instantiated from 'Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = boost::archive::class_id_type, Archive = portable_binary_iarchive]'
/projects/lib/BOOST/1_44_0/include/boost/archive/detail/common_iarchive.hpp:51: instantiated from 'void boost::archive::detail::common_iarchive<Archive>::vload(boost::archive::class_id_type&) [with Archive = portable_binary_iarchive]'
/home/myfolder/src/portable_binary_iarchive.cpp:128: instantiated from here
/home/myfolder/src/portable_binary_iarchive.hpp:107: error: call of overloaded 'class_id_type(intmax_t&)' is ambiguous
/projects/lib/BOOST/1_44_0/include/boost/archive/basic_archive.hpp:118: note: candidates are: boost::archive::class_id_type::class_id_type(size_t)
/projects/lib/BOOST/1_44_0/include/boost/archive/basic_archive.hpp:115: note: boost::archive::class_id_type::class_id_type(int)
Not really a direct answer to your question, but I've had a lot of success with Google's Protocol Buffers. They use them internally and open sourced them: http://code.google.com/p/protobuf/
I built with g++ 4.1.2 and it works fine. I hate bjam, it's hard to see what is happening, and it's unbelievably slow.
There was a warning about a deprecated header, and since this has the earmarks of a deprecated friend declaration, I was hoping to see something old, but I don't.
Did you build it with bjam or did you try to pull out the serialization into your own directory and do it yourself? Because your directory structure is not exactly like the one they have in the package.
#define private public
ought to get rid of the first error about accessing private members. It's a bit cheeky! But it can work as a temporary fix until you've understood the whole program better.