c++ - 如何将 SWIG 与 "using"一起使用

标签 c++ ocaml swig oracle-coherence

我正在尝试在 C++ 库上使用 SWIG 2.0.4,我的 .i 中有以下内容 文件:

%module coh
%{
#include "coherence/lang.ns"
#include "coherence/net/CacheFactory.hpp"
#include "coherence/net/NamedCache.hpp"
%}

%include "coherence/lang.ns"
%include "coherence/net/CacheFactory.hpp"
%include "coherence/net/NamedCache.hpp"

我用它来喝:

$ swig -c++ -ocaml -I/opt/coherence-cpp/include coh.i

但收到错误消息:

/opt/coherence-cpp/include/coherence/net/CacheFactory.hpp:31: Error: Syntax error in input(1)

该文件的第 31 行是:

using coherence::run::xml::XmlElement;

不支持 using 关键字吗?是否有解决方法,或者我应该编写自己的 C++ 包装器,然后使用 SWIG 来代替?谢谢!

更新:我决定write my own wrapper (将来,从一开始就采取不同的方法)。

最佳答案

MSDN有这样说:

Note the difference between the using directive and the using declaration : the using declaration allows an individual name to be used without qualification, the using directive allows all the names in a namespace to be used without qualification.

(我猜)SWIG 支持“using 指令”,但不支持“using 声明”。

也就是说,你可以使用:

using namespace somenamespace::mynamespace;

但是你不能使用:

using somenamespace::mynamespace::MySymbol;

关于c++ - 如何将 SWIG 与 "using"一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6874132/

相关文章:

ocaml - 如何在ocaml中安装corebuild

python - 为 C 库创建 Python 绑定(bind)的 SWIG 问题

java - 使用 SWIG 将 char * 类型结构的成员转换为 Java 中的 java.lang.Object

c++ - 当堆栈溢出发生时

c++ - 类的对象(使用单/多继承)有多少个 vptr?

error-handling - OCaml 用户定义类型和函数返回错误

OCaml 物理和结构平等

python - 如何将 Python 中的字节对象传递给用 Swig 包装的 C++ 函数?

c++ - 如何将类方法转换为 QScriptEngine::FunctionSignature

c++ - 在 wincrypt 中设置 KP_P 时 CryptSetKeyParam 中的 NTE_BAD_DATA