我正在尝试在 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/