swig和c++ 11的兼容性
swig and C++11 compatibility
我正在尝试为一个复杂的项目创建一个python模块,该项目使用了c++ 11中的一些新功能(https://code.google.com/p/cpp-array/)。我的接口文件很简单:
%module array
%{
#include "array-config.hpp"
#include "array.hpp"
%}
%include "array-config.hpp"
%include "array.hpp"
但是当我运行swig时,我得到了很多错误。
第一个错误是constexprconstexpr static int dim()
{ return d; }
因此,如果我删除constexpr,我可以绕过这个错误。根据http://www.swig.org/Doc3.0/CPlusPlus11.html中的文档,处理这个关键字。
第二个是当找到这个函数时:
template <int d, typename U, typename... Args>
typename std::enable_if<std::is_integral<U>::value and !std::is_pointer<U>::value and d < k, void>::type
init(U i, Args&&... args) {
assert(i != 0); // Array dimension cannot be zero
n_[d] = i;
init<d+1>(args...);
}
我只是想用swig"为真正懒惰的人",但我开始怀疑这在这一点上是否可能。我是否必须复制整个头文件并开始进行调整才能使此工作?因为我刚开始喝酒,我希望你能给我一些建议。
您可以将任何SWIG不喜欢的内容包装在#ifdef
例如,我正在使用我们使用的SWIG版本不支持的c++ 11块。所以我这样做:
namespace glue {
class GlueServer {
public:
virtual void handle(std::string path, GlueHandlerFunc handler, void* arg) = 0;
#ifndef SWIG
virtual void handleBlock(std::string path, void (^b)(GlueRequest* req)) = 0;
#endif
// ...
相关文章:
- 将成员变量添加到共享库中的类中,不会破坏二进制兼容性吗
- 提升序列化 1:73 的向后兼容性问题
- 在gcc中意外调用了Const重载.编译器错误或兼容性修复程序
- 各种版本的 Mac OSX 向后兼容性如何?(Xcode C++
- Visual Studio 19-17 库兼容性根据 GL 标志
- C++ ABI 兼容性问题/张量流
- Oracle OCCI 和 g++ 7.1 的兼容性问题
- 为什么库API+编译器ABI足以确保具有不同版本gcc的对象之间的兼容性
- 对指针和恒常性兼容性的引用
- 检查操作系统兼容性
- 添加noexcept是否会破坏二进制兼容性
- 右值需要分配什么向后兼容性
- 如何在不添加对库的依赖的情况下添加与库结构的兼容性
- 在Qt中使用C++Lambda函数作为插槽是否有助于保持库的二进制兼容性?
- python 和 swig 版本兼容性问题
- Tensorflow C++ API 和 Caffe 兼容性问题与 Glog 相关
- 当要求兼容性时,核心OpenGL上下文?
- 启用和禁用 RTTI 的模块之间的兼容性
- 值为 std::string,同时保持向后兼容性
- 将 OpenGL 兼容性配置文件与英特尔 HD GPU + Mesa 结合使用