if you have a .i file
%module module1
%module module2
SWIG just accepts it without comment. It should generate a warning on this matter.
Note: I think one of the test-suite actually has this code, so generating an error is not desirable result.
This is still the case. The second %module isn't ignored entirely it seems - it looks like any parameters will be handled as if they were all present in a single %module but the name is ignored. That doesn't really seem an intentional or very useful feature though.
We can't just warn if the name is already set though as that's how the documented -module overriding %module is implemented.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
commitfaf8fee8772c8d26ce184854aede993edc728676Author:WilliamSFulton<wsf@fultondesigns.co.uk>Date:ThuMar418:27:232010+0000minorcommentaddedgit-svn-id:https://swig.svn.sourceforge.net/svnroot/swig/trunk@11894 626c5289-ae23-0410-ae9c-e8d60b6d4f22diff--gita/Examples/test-suite/extend_template.ib/Examples/test-suite/extend_template.iindexa39ac546..265c8767100644---a/Examples/test-suite/extend_template.i+++b/Examples/test-suite/extend_template.i@@-1,5+1,5@@%moduleextend_template-%modulexxx+%modulexxx// should be ignorednamespaceoss{// this doesn't %extendFoo<0>{inttest1(intx){returnx;}
So it seems at least back then this was expected to be ignored.
There is however a documented warning:
316.Repeated%moduledirective.
However nothing currently seems to actually emit warning 316 or WARN_PARSE_MODULE_REPEAT. I also don't see anything in git history which does, but it's hard to check history for 316 as it's very noisy even as a word.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We also rely on this being accepted in some testcases - e.g. preproc_constants_c.i contains %include "preproc_constants.i" but both contain %module directives.
I can see an argument for warning about this, but %module is both conventionally and most naturally put at the very top of the file, so in practice I don't think this situation is going to occur in a way which causes confusion in real world use.
Fixing would seem to require adding a warning and adjusting all the uses in the testsuite to either suppress that warning, or reworking so cases like the above have a stub for both C and C++ variants which both %include a third interface file without %module. That seems more effort than justified by the marginal benefit.
Given we've had this open since 2007 and nobody's cared enough to come up with a patch in all that time I'm going to close as "won't fix".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is still the case. The second
%moduleisn't ignored entirely it seems - it looks like any parameters will be handled as if they were all present in a single%modulebut the name is ignored. That doesn't really seem an intentional or very useful feature though.We can't just warn if the name is already set though as that's how the documented
-moduleoverriding%moduleis implemented.Examples/test-suite/extend_template.ihas:The extra module statement uselessly shows as added by:
But the comment was added by:
So it seems at least back then this was expected to be ignored.
There is however a documented warning:
However nothing currently seems to actually emit warning 316 or
WARN_PARSE_MODULE_REPEAT. I also don't see anything in git history which does, but it's hard to check history for 316 as it's very noisy even as a word.We also rely on this being accepted in some testcases - e.g.
preproc_constants_c.icontains%include "preproc_constants.i"but both contain%moduledirectives.I can see an argument for warning about this, but
%moduleis both conventionally and most naturally put at the very top of the file, so in practice I don't think this situation is going to occur in a way which causes confusion in real world use.Fixing would seem to require adding a warning and adjusting all the uses in the testsuite to either suppress that warning, or reworking so cases like the above have a stub for both C and C++ variants which both
%includea third interface file without%module. That seems more effort than justified by the marginal benefit.Given we've had this open since 2007 and nobody's cared enough to come up with a patch in all that time I'm going to close as "won't fix".