第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

SWIG 在 Windows 中生成 C++ Python3 包裝器導(dǎo)致斷言 MSVC 2017

SWIG 在 Windows 中生成 C++ Python3 包裝器導(dǎo)致斷言 MSVC 2017

牛魔王的故事 2021-08-17 17:06:29
使用 SWIG 圍繞 C++ 類生成包裝器會(huì)在運(yùn)行時(shí)導(dǎo)致奇怪的斷言:Assertion failed!Program: C:\Python37\python37_d.dllFile: c:\_work\4\s\objects\typeobject.cLine: 3634Expression: PyTuple_Check(args)For information on how your program can cause an assertionfailure, see the Visual C++ documentation on asserts(Press Retry to debug the application - JIT must be enabled)如果在彈出的對話框上點(diǎn)擊忽略,一切似乎都正常。我創(chuàng)建了一個(gè)示例程序來嘗試復(fù)制問題并遇到了同樣的問題:主程序#include "testwrapper.h"#pragma push_macro("slots")#undef slots#include "Python.h"#pragma pop_macro("slots")#include "SwigModules/generated/swig_runtime.h"PyObject * ConvertToWrapper(SwigInterface * instance){    swig_type_info * pTypeInfo = SWIG_TypeQuery("SwigInterface *");    PyObject* obj = SWIG_NewPointerObj(instance, pTypeInfo, 0); <- issue occurs here    return obj;}TestWrapper * wrapper = new TestWrapper();void TestSwig(){  Py_Initialize();  PyRun_SimpleString("import test_module");  ConvertToWrapper(wrapper);  Py_Finalize();}int main(int argc, char *argv[]){  TestSwig();  return 0;}測試包裝器.h#pragma once#include "swiginterface.h"class TestWrapper : public  SwigInterface{public:  TestWrapper(){}  virtual ~TestWrapper(){}  virtual void Test();};swiginterface.h#pragma onceclass SwigInterface{public:  virtual ~SwigInterface(){}  virtual void Test() = 0;};test_module.i(swig 接口文件)%module test_module%{#include "../swiginterface.h"%}%include "../SwigInterface.h"%inline %{  SwigInterface * test;%}setup_function (python)from distutils.core import setup, Extensionsetup(name="test_module",      py_modules=['test_module'],      ext_modules=[Extension("_test_module",                     ["test_module.i"],                     extra_compile_args=["-DSWIG_TYPE_TABLE=test_module"],                     swig_opts=["-c++", "-py3"],                  )])
查看完整描述

2 回答

?
ABOUTYOU

TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個(gè)贊

或者升級(jí)到 SWIG 4.0,它有一個(gè)修復(fù)


查看完整回答
反對 回復(fù) 2021-08-17
?
海綿寶寶撒

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊

為了解決這個(gè)問題,我需要從 Python3.7 降級(jí)到 Python3.6


查看完整回答
反對 回復(fù) 2021-08-17
  • 2 回答
  • 0 關(guān)注
  • 292 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)