OS: Windows 10
IDE: Visual Studio 2015
I need to use the AsmJit library (https://github.com/asmjit/asmjit) inside my Qt GUI Application. But is is somehow incompatible. When certain headers are included from QT (QWidget etc.), things start to break.
Most errors originate from this line:
ASMJIT_INLINE Error emit(uint32_t code, const Operand& o0, const Operand& o1, const Operand& o2, const Operand& o3) {
return _emit(code, o0, o1, o2, o3);
}
Where ASMJIT_INLINE
is defined as __forceinline
.
When I compile it in VS2015, it is giving the following error:
Severity Code Description Project File Line Suppression State
Error C2086 'asmjit::Error asmjit::Assembler::Operand': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 472
Error C2334 unexpected token(s) preceding '{'; skipping apparent function body Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 472
Error C2238 unexpected token(s) preceding ';' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 466
Error C2238 unexpected token(s) preceding ';' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 468
Error C2238 unexpected token(s) preceding ';' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 470
Error C2238 unexpected token(s) preceding ';' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 481
Error C2238 unexpected token(s) preceding ';' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 483
Error C2238 unexpected token(s) preceding ';' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 485
Error C2238 unexpected token(s) preceding ';' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 487
Error C2238 unexpected token(s) preceding ';' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 489
Error C2238 unexpected token(s) preceding ';' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 491
Error C2062 type 'int' unexpected Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 477
Error C2146 syntax error: missing '>' before identifier 'uint64_t' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 248
Error C2146 syntax error: missing '>' before identifier 'uint32_t' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 242
Error C2146 syntax error: missing '>' before identifier 'uint32_t' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 260
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 466
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 468
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 470
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 472
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 481
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 483
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 485
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 487
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 489
Error C2143 syntax error: missing ';' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 491
Error C2143 syntax error: missing ',' before '&' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 494
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 464
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 466
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 468
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 470
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 472
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 477
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 479
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 481
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 483
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 485
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 487
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 489
Error C2146 syntax error: missing ')' before identifier 'code' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 491
Error C2061 syntax error: identifier 'uint64_t' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 284
Error C2061 syntax error: identifier 'uint32_t' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 278
Error C2061 syntax error: identifier 'uint32_t' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 296
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 464
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 466
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 468
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 470
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 472
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 479
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 481
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 483
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 485
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 487
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 489
Error C2059 syntax error: ')' Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 491
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 494
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 242
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 248
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 260
Error C3646 'o0': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 479
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 464
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 466
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 468
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 470
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 472
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 477
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 479
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 481
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 483
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 485
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 487
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 489
Error C3646 'code': unknown override specifier Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 491
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 466
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 468
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 470
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 472
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 477
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 479
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 481
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 483
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 485
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 487
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 489
Error C2086 'asmjit::Error asmjit::Assembler::uint32_t': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 491
Error C2086 'asmjit::Error asmjit::Assembler::Operand': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 468
Error C2086 'asmjit::Error asmjit::Assembler::Operand': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 470
Error C2086 'asmjit::Error asmjit::Assembler::Operand': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 481
Error C2086 'asmjit::Error asmjit::Assembler::Operand': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 483
Error C2086 'asmjit::Error asmjit::Assembler::Operand': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 485
Error C2086 'asmjit::Error asmjit::Assembler::Operand': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 487
Error C2086 'asmjit::Error asmjit::Assembler::Operand': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 489
Error C2086 'asmjit::Error asmjit::Assembler::Operand': redefinition Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 491
Error C2327 'asmjit::Assembler::uint32_t': is not a type name, static, or enumerator Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 494
Error C2327 'asmjit::Assembler::uint32_t': is not a type name, static, or enumerator Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 513
Error C2433 'asmjit::Assembler::uint32_t': '__forceinline' not permitted on data declarations Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 472
Error C2433 'asmjit::Assembler::Operand': '__forceinline' not permitted on data declarations Loader C:\Users\Ik\Documents\Visual Studio 2015\Projects\DC\loader\CustomBone\contrib\AsmJit\base\assembler.h 472
After thinking about this I think the only reason that asmjit doesn't compile with Qt is that qt defines emit
macro, which collides with asmjit's emit
function. So after expanding the macro the code:
ASMJIT_INLINE Error emit(uint32_t code,
const Operand& o0,
const Operand& o1,
const Operand& o2,
const Operand& o3) { return _emit(code, o0, o1, o2, o3); }
Becomes:
ASMJIT_INLINE Error (uint32_t code,
const Operand& o0,
const Operand& o1,
const Operand& o2,
const Operand& o3) { return _emit(code, o0, o1, o2, o3); }
Using Qt with 3rd Party Signals and Slots (https://doc.qt.io/qt-5/signalsandslots.html) mentions it:
no_keywords
tells Qt not to define the moc keywords signals, slots, and emit, because these names will be used by a 3rd party library, e.g. Boost. Then to continue using Qt signals and slots with the no_keywords flag, simply replace all uses of the Qt moc keywords in your sources with the corresponding Qt macros Q_SIGNALS (or Q_SIGNAL), Q_SLOTS (or Q_SLOT), and Q_EMIT.
Adding no_keywords
to Qt project is the same as passing -DQT_NO_KEYWORDS
to the compiler (basically defining QT_NO_KEYWORDS
to 1).
This could be fixed on asmjit side as well, however, asmjit is doing nothing wrong. You would have the same problem with many other libraries like boost.