调试SWIG%忽略

时间:2017-01-09 10:17:10

标签: c++ swig

我正在尝试将%ignore转换为MyNamespace::SubNamespace::MyClass::operator->()符号%ignore。我尝试了一百万种不同的%ignore operator->;

组合
  • %ignore operator ->;
  • %ignore operator ->();
  • %ignore *::operator->;
  • %ignore MyNamespace::SubNamespace::MyClass::operator->;
  • %ignore MyNamespace::SubNamespace::MyClass;

地狱甚至...MyFile.hpp:267: Warning 508: Declaration of 'operator <' shadows declaration accessible via operator->(), ...MyFile.hpp:192: Warning 508: previous declaration of 'operator <'. 似乎没有做任何事情。在每种情况下,我都会收到此错误:

%ignore

这是由this SWIG code引起的,这似乎与智能指针有关。但是从operator->() %ignore这样的代码看起来应该删除警告。在任何情况下都应忽略整个班级。

所以我的问题是,有没有办法调试QML。据我所知,看起来你必须继续尝试组合,直到它工作。有没有办法打印出SWIG的符号列表?代码看起来没有任何日志工具。

1 个答案:

答案 0 :(得分:0)

我没有特别为#include <iostream> #include <unistd.h> #include <fcntl.h> const int PIPE_READ = 0; const int PIPE_WRITE = 1; int main() { int pfd[2]; if(pipe(pfd) == -1){ std::cout << "Cannot create pipe" << std::endl; return 0; } int pid = fork(); if(pid == -1){ std::cout << "Error on fork: " << errno << std::endl; } else if(pid == 0) { // Child process if(dup2(pfd[PIPE_WRITE],STDOUT_FILENO) < 0) { std::cout << "Cannot redirect STDOUT: " << errno << std::endl; return 0; } close(pfd[PIPE_WRITE]); for(int i = 0; i < 8; i++){ int data = i; write(STDOUT_FILENO,&data,sizeof(int)); // Works //std::cout << data; // Don't work } } else { // Parent process close(pfd[PIPE_WRITE]); for(int i = 0; i < 8; i++){ int data; ssize_t status; if((status = read(pfd[PIPE_READ],&data,sizeof(int))) != sizeof(int)) { std::cout << "Error (" << errno << ") on read: " << status << std::endl; return -1; } std::cout << data << std::endl; } } return 0; } 找到选项,但有各种%ignore命令行选项。特别是-debug-...让我发现-debug-symbols operator->()%rename__deref__ swig.swg,默认情况下包含在所有文件中。

我尝试了%ignore __deref__;和一些变体,但这些都不起作用。

我甚至最终修改了代码以检测%ignore s(提示:

/* Create a name applying rename/namewarn if needed */
static String *apply_rename(String *newname, int fullname, String *prefix, String *name) {
  String *result = 0;
  if (newname && Len(newname)) {
    if (Strcmp(newname, "$ignore") == 0) {
        printf("Renaming to ignore: %s\n", Char(name));
      result = Copy(newname);

)但这些名称似乎都没有名称空间。实际上,关于两个operator<的警告是在不同的类中(尽管一个是另一个的朋友)并且据我所知,SWIG只是查找是否还有其他operator<的。可能是命名空间错误。