English 中文(简体)
由于预处理指令, SWIG 错误
原标题:SWIG errors because of preprocessor directive

我们有一个供应商为我们提供了C++图书馆和信头,我正试图用SWIG包起来。他们似乎对预处理指令太聪明了:

// top.h
#define DECLARE_WITH_COMMA(a) a,

时和时

// foo.h
#include "top.h"

#define MY_TYPES(d) 
  d(One)   
  d(Two)   
  d(Three) 
  NumElems

enum MyTypes {
  MY_TYPES(DECLARE_WITH_COMMA)
};

当我尝试运行SWIG(2.0.4版)关于“foo.h”的版本时,

foo.h:12: Error: Syntax error in input(1).

因此,我的问题是,鉴于我可能不想改变 供应商供应信头,我有什么选择呢?

最佳回答

SWIG 默认情况下不会在嵌套信头中循环, 所以您的 . i 文件应该看起来像 :

%module mymod

%{
#include "foo.h"
%}

%include "top.h"
%include "foo.h"

也有一个SWIG开关:

-includeall     - Follow all #include statements

假若你们有系统信头,而系统信头的功绩超过你们所希望的。

问题回答

暂无回答




相关问题
Can you #define a comment in C?

I m trying to do a debug system but it seems not to work. What I wanted to accomplish is something like this: #ifndef DEBUG #define printd // #else #define printd printf #endif Is there a ...

C Programming: Preprocessor, macros as tokens

I m trying to do something that is conceptually similar to this, but can t seem to get it to work (error shown at end) any ideas? #include <stdio.h> int main( int argc , char const *argv[] ) { ...

Testrun preprocessor statement

Is there a way to set a constant depending on whether unit tests are run? The problem with the unit test framework is de way it deals with dependencies; it will copy files but it does not seem to ...

C macro processing

I m thinking about best way to write C define processor that would be able to handle macros. Unfortunately nothing intelligent comes to my mind. It should behave exactly like one in C, so it handles ...

Macros as arguments to preprocessor directives

Being faced with the question whether it s possible to choose #includes in the preprocessor I immediately thought not possible. .. Only to later find out that it is indeed possible and you only need ...

See what the preprocessor is doing

Is there anyway to see what you code looks like after the preprocessor has done all the substitutions?

Removing macro in legacy code

I have a lot of legacy code using macro of the form: #define FXX(x) pField->GetValue(x) The macro forces variable pField be in the scope: ..... FIELD *pField = .... ..... int i = FXX(3); int j = ...

热门标签