From: William S F. <ws...@fu...> - 2009-03-10 06:26:03
|
Robert Lupton the Good wrote: > The following .i file generates a syntax error; remove the comment in > %FOO > and all is well. It's something about expanding an argument within a > comment, and I'd guess that the result of expanding %GOO includes the > newline > (which is usually what you want) --- so the ABC appears on a line of > its own. > > If I'm right, we should strip comments before expanding macro arguments. > > R > > > %module foo; > > %define %GOO(ARG1) > ARG1 x; > %enddef > > %define %FOO(ARG2) > // ARG2 ABC > %enddef > > %FOO(%GOO(float)); > To me it is doing the right thing. %GOO(float) expands to (where \n is a newline): \nfloat x;\n So %FOO(%GOO(float)) is then: \n// \nfloat x;\n ABC\n If you run swig -E, you'll see the resulting output, eg using this: /*start*/%FOO(%GOO(float));/*end*/ you'll get: /*start*//*@SWIG:example.i,10,%FOO@*/ // /*@SWIG:example.i,6,%GOO@*/ float x; /*@SWIG@*/ ABC /*@SWIG@*/;/*end*/ Consider using C comments rather than C++ comments as that will give you what you want. William |