【问题标题】:Warning 325: Nested class not currently supported (Proxy ignored)警告 325:当前不支持嵌套类(忽略代理)
【发布时间】:2017-08-11 02:19:44
【问题描述】:

我在运行 swig 接口文件时收到以下警告 警告 325:当前不支持嵌套类(忽略代理)。 我能够取消警告。但我需要嵌套类进行计算

下面是接口文件(example.i)

%module example
%{
#include "Rinside.h"
#include "Rinsidecommon.h"
#include "Callbacks.h"
%}
/* Let's just grab the original header file here */
%include "Rinside.h"
%include "Rinsidecommon.h"
%include "Callbacks.h"

在执行接口文件时。以下是警告

C:\swigwin-3.0.12\Examples\r\Rinside>swig -tcl -c++ example.i
Rinside.h(70) : Warning 325: Nested class not currently supported (Proxy ignored)
Rinside.h(91) : Warning 503: Can't wrap 'operator []' unless renamed to a valid identifier.

我正在尝试从 Tcl 调用 RInside。首先,我的 C 代码应该能够接受参数,通过传递这些参数调用 RInside,并打印 RInside 执行的结果

下面是我在 Rinside.h 文件中的嵌套类。 如何在接口文件中包含嵌套类? 我对 swig 比较陌生

    class Proxy {
public:
    Proxy(SEXP xx): x(xx) { };

    template <typename T>
    operator T() {
        return ::Rcpp::as<T>(x);
    }
private:
    Rcpp::RObject x;
};

谁能给我一个骨架或部分代码。对我有帮助

包装 cpp 代码时出现以下错误

rinside_sample0_wrap.cxx: In function 'int _wrap_RInside_parseEval__SWIG_1(ClientData, Tcl_Interp*, int, Tcl_Obj* const*)':\
rinside_sample0_wrap.cxx:1906:18: error: no matching function for call to 'RInside::Proxy::Proxy()'
In file included from rinside_sample0_wrap.cxx:1700:0:
Rinside.h:61:6: note: candidate: RInside::Proxy::Proxy(SEXP)
Proxy(SEXP xx): x(xx) { };
Rinside.h:61:6: note:   candidate expects 1 argument, 0 provided

【问题讨论】:

  • 向我们展示一个重现问题的最小完整示例界面。
  • 已编辑请帮忙

标签: c++ tcl swig


【解决方案1】:

我刚刚遇到了与 python 相同的问题。当我将3.0.12 与嵌套类一起使用时,我只会看到警告:

Warning 325: Nested class not currently supported (Foo ignored)

所以我使用了以下功能:

   %module test
   %feature("flatnested", "1");

   %rename (Bar_Foo) Bar::Foo;
   class Foo {};
   class Bar {
    public:
    class Foo {};
   };

实际上,在我的问题中,我在需要它的特定情况后再次禁用了该功能(因为它导致枚举类出现问题)。

【讨论】:

    【解决方案2】:

    根据SWIG Documentation

    兼容性说明: 在 SWIG-3.0.0 之前,对嵌套类的支持有限。嵌套类被视为不透明指针。但是,在这些旧版本中存在嵌套类支持的解决方法,要求用户在全局范围内复制嵌套类,为全局范围内的嵌套类添加 typedef 并在嵌套类上使用“nestedworkaround”功能.这导致了与“扁平化”功能大致相同的行为。由于 SWIG-3.0.0 现在提供了适当的嵌套类支持,此功能已被弃用,不再需要更改代码。

    因此,您应该使用 3.0 或更高版本来支持嵌套类。这将使您避免需要抑制任何内容,并且还可以解决您的其他问题。

    【讨论】:

    • 但我一直在使用 swig - 3.0.12 版本。我仍然不明白为什么我会收到警告和错误
    • 那样的话,我不知道怎么回事。这听起来像是违反了一些基本假设。联系 SWIG 作者/维护者寻求帮助...
    猜你喜欢
    • 2022-06-23
    • 1970-01-01
    • 1970-01-01
    • 2021-06-03
    • 2015-03-10
    • 2010-10-07
    • 1970-01-01
    • 2020-11-03
    • 1970-01-01
    相关资源
    最近更新 更多