在Qt GUI应用程序中使用AsmJit时出错

时间:2017-02-10 00:59:23

标签: qt asmjit

操作系统:Windows 10

IDE:Visual Studio 2015

我需要在Qt GUI应用程序中使用AsmJit库(https://github.com/asmjit/asmjit)。但是在某种程度上是不相容的。当QT(QWidget等)中包含某些标题时,事情就会开始中断。

大多数错误都来自这一行:

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);
  }

ASMJIT_INLINE定义为__forceinline

当我在VS2015中编译它时,它出现以下错误:

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 

1 个答案:

答案 0 :(得分:1)

考虑到这一点后,我认为asmjit不能用Qt编译的唯一原因是qt定义了loadMoreItems宏,它与asmjit的emit函数发生冲突。所以在扩展宏代码之后:

emit

变为:

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); }

将Qt与第三方信号和插槽(https://doc.qt.io/qt-5/signalsandslots.html)一起使用提到:

  

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); } 告诉Qt不要定义moc关键字信号,插槽和发射,因为这些名称将由第三方库使用,例如促进。然后继续使用带有no_keywords标志的Qt信号和插槽,只需将源中Qt moc关键字的所有使用替换为相应的Qt宏Q_SIGNALS(或Q_SIGNAL),Q_SLOTS(或Q_SLOT)和Q_EMIT。

no_keywords添加到Qt项目与将no_keywords传递给编译器(基本上将-DQT_NO_KEYWORDS定义为1)相同。

这也可以在asmjit方面修复,但是,asmjit没有做错任何事。对于许多其他库,例如boost,你会遇到同样的问题。