- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设我在头文件 A.h 中有两个类 A
// A.h
class A {
public:
void foo();
};
// B.h
class B : public A {
public:
void bar()
};
B.i
%{
#include "B.h"
%}
%include B.h
最佳答案
我把一个例子放在一起,只得到一个警告,说对 A 一无所知。扩展仍然可以很好地构建,并且可以在不知道 A 的 bar() 的情况下调用 B 的 foo()。这是我为 Windows 生成 Python 扩展的示例:
构建输出
C:\example>nmake /las
b.cpp
a.cpp
Generating Code...
Creating library b.lib and object b.exp
B.h(12) : Warning 401: Nothing known about base class 'A'. Ignored.
b_wrap.cxx
Creating library _b.lib and object _b.exp
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import b
>>> b.B().bar()
In B::bar()
>>> b.B().foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "b.py", line 73, in <lambda>
__getattr__ = lambda self, name: _swig_getattr(self, B, name)
File "b.py", line 54, in _swig_getattr
raise AttributeError(name)
AttributeError: foo
#pragma once
#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif
class DLL_API A
{
public:
void foo();
};
#pragma once
#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif
#include "a.h"
class DLL_API B : public A
{
public:
void bar();
};
#include <stdio.h>
#define DLL_EXPORTS
#include "a.h"
void A::foo()
{
printf("In A::foo()\n");
}
#include <stdio.h>
#define DLL_EXPORTS
#include "b.h"
void B::bar()
{
printf("In B::bar()\n");
}
%module b
%begin %{
#pragma warning(disable:4100 4127 4706)
%}
%{
#include "B.h"
%}
%include <windows.i>
%include "B.h"
_b.pyd: b.dll b_wrap.cxx
cl /nologo /EHsc /LD /W4 b_wrap.cxx /I c:\Python26\include /Fe_b.pyd -link /nologo /libpath:c:\Python26\libs b.lib
b_wrap.cxx: b.i
swig -c++ -python b.i
b.dll: a.cpp b.cpp
cl /nologo /LD /W4 b.cpp a.cpp
关于interface - 避免 swig 中出现 'nothing known about [parent] class...' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4483614/
016-03-07T09:10:16.992-0600 W NETWORK [HostnameCanonicalizationWorker] Failed to obtain name info f
我有一个工作的 C 程序,其中字符串数组的长度在编译时已知。它是: char array_person_name[3][101]; char person_name[101] = ""; ... st
我正在做一个需要Graph DB 的项目。我正在使用 C# .Net Core 开发项目。我不得不选择 ArangoDB 作为这个项目的 Graph DB。不幸的是,.Net 没有官方驱动程序。这就是
我正在尝试使用 DataContractSerializer 将对象序列化为 Xml。我有以下类(class); [ActiveRecord(Lazy = true)] [KnownType(type
我有: 身份服务器 4, 具有 OpenId Connect 和混合流的 Mvc 应用 WebApi 应用 假设用户已经获得带有 id_token 和访问 token 的 cookie。然后他从 mv
我有: 身份服务器 4, 具有 OpenId Connect 和混合流的 Mvc 应用 WebApi 应用 假设用户已经获得带有 id_token 和访问 token 的 cookie。然后他从 mv
我有一个简单的 Asp.Net Core Azure Web 应用程序,需要向本地 Rest 服务发出 http get 请求。此 Rest 服务托管在 IIS 上,仅针对端口 443 设置了绑定(b
这个问题可能是一个很好回答的问题,但不幸的是我不知道正确的术语来正确地问它,所以...... template class __bit_iterator; 有人可以在这里解释最后一个模板参数吗?我唯
在基于ASP.NET Core 1.1.1开发的VS2017 Ver 15.3.3应用程序中,我使用Account confirmation and password recovery in ASP.
我有一个应用程序(aspnet core app 3.1),在启动期间使用以下代码从 azure blob 存储加载数据: BlobClient client = new BlobClient(loa
我有一个应用程序(aspnet core app 3.1),在启动期间使用以下代码从 azure blob 存储加载数据: BlobClient client = new BlobClient(loa
我想知道如何查询Wikidata通过使用别名(“也称为”)。 现在我正在努力 SELECT ?item WHERE { ?item rdfs:aliases ?alias. FILTER(CONTAI
这是一个 PNG 类,在类文档中列出了两个构造函数,如下所示。 PNG::PNG ( string const & file_name ) Creates a PNG image
这就是我目前拥有的,以及我的教授提供的扫描仪。 #include "Similarity.h" #include "Scanner.h" using namespace std; int Simila
我想从我的 asp 页面连接到 mysql 数据库。因此,根据我的托管服务提供商的说法,我使用了连接字符串,其中服务器被指定为“localhost:3309” Dim myConnection As
我正在尝试集成的第三方应用程序,要求将文件放入 .well-known文件夹。如何使该文件可从 URL 访问? ( example.com/.well-known/token.txt )。站点部署为
尝试学习 Hibernate,我正在尝试学习如何执行 NamedQuries但每次我都会收到 Exception in thread "main" org.hibernate.MappingExcep
我正在尝试将 PWA 发布到 Google Playstore。我被困在数字 Assets 握手中。 这是我的 nginx conf - location /asd/ { default_t
我正在尝试设置 wordpress xml-rpc带 rails : blog = XMLRPC::Client.new("localhost/blog", "/xmlrpc.php", 80) 但是
我在我的 nginx 配置中有这个: location ~ /\. { deny all; } location /.well-known/ { allow all; } 但是我还是不
我是一名优秀的程序员,十分优秀!