/trunk/Doc/Manual/Warnings.html
HTML | 595 lines | 492 code | 101 blank | 2 comment | 0 complexity | 06e34ba081b97d0c429eee1772e3b085 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>Warning Messages</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body bgcolor="#ffffff">
- <H1><a name="Warnings"></a>14 Warning Messages</H1>
- <!-- INDEX -->
- <div class="sectiontoc">
- <ul>
- <li><a href="#Warnings_nn2">Introduction</a>
- <li><a href="#Warnings_suppression">Warning message suppression</a>
- <li><a href="#Warnings_nn4">Enabling extra warnings</a>
- <li><a href="#Warnings_nn5">Issuing a warning message</a>
- <li><a href="#Warnings_symbolic_symbols">Symbolic symbols</a>
- <li><a href="#Warnings_nn6">Commentary</a>
- <li><a href="#Warnings_nn7">Warnings as errors</a>
- <li><a href="#Warnings_nn8">Message output format</a>
- <li><a href="#Warnings_nn9">Warning number reference</a>
- <ul>
- <li><a href="#Warnings_nn10">Deprecated features (100-199)</a>
- <li><a href="#Warnings_nn11">Preprocessor (200-299)</a>
- <li><a href="#Warnings_nn12">C/C++ Parser (300-399)</a>
- <li><a href="#Warnings_nn13">Types and typemaps (400-499) </a>
- <li><a href="#Warnings_nn14">Code generation (500-599)</a>
- <li><a href="#Warnings_nn15">Language module specific (700-899) </a>
- <li><a href="#Warnings_nn16">User defined (900-999)</a>
- </ul>
- <li><a href="#Warnings_nn17">History</a>
- </ul>
- </div>
- <!-- INDEX -->
- <H2><a name="Warnings_nn2"></a>14.1 Introduction</H2>
- <p>
- During compilation, SWIG may generate a variety of warning messages. For example:
- </p>
- <div class="shell">
- <pre>
- example.i:16: Warning 501: Overloaded declaration ignored. bar(double)
- example.i:15: Warning 501: Previous declaration is bar(int)
- </pre>
- </div>
- <p>
- Typically, warning messages indicate non-fatal problems with the input
- where the generated wrapper code will probably compile, but it may not
- work like you expect.
- </p>
- <H2><a name="Warnings_suppression"></a>14.2 Warning message suppression</H2>
- <p>
- All warning messages have a numeric code that is shown in the warning message itself.
- To suppress the printing of a warning message, a number of techniques can be used.
- First, you can run SWIG with the <tt>-w</tt> command line option. For example:
- </p>
- <div class="shell">
- <pre>
- % swig -python -w501 example.i
- % swig -python -w501,505,401 example.i
- </pre>
- </div>
- <p>
- Alternatively, warnings can be suppressed by inserting a special preprocessor pragma
- into the input file:
- </p>
- <div class="code">
- <pre>
- %module example
- #pragma SWIG nowarn=501
- #pragma SWIG nowarn=501,505,401
- </pre>
- </div>
- <p>
- Finally, code-generation warnings can be disabled on a declaration by declaration basis using
- the <tt>%warnfilter</tt> directive. For example:
- </p>
- <div class="code">
- <pre>
- %module example
- %warnfilter(501) foo;
- ...
- int foo(int);
- int foo(double); // Silently ignored.
- </pre>
- </div>
- <p>
- The <tt>%warnfilter</tt> directive has the same semantics as other declaration modifiers like
- <tt>%rename</tt>, <tt>%ignore</tt> and <tt>%feature</tt>, see the
- <a href="Customization.html#Customization_features">%feature directive</a> section. For example, if you wanted to
- suppress a warning for a method in a class hierarchy, you could do this:
- </p>
- <div class="code">
- <pre>
- %warnfilter(501) Object::foo;
- class Object {
- public:
- int foo(int);
- int foo(double); // Silently ignored
- ...
- };
- class Derived : public Object {
- public:
- int foo(int);
- int foo(double); // Silently ignored
- ...
- };
- </pre>
- </div>
- <p>
- Warnings can be suppressed for an entire class by supplying a class name. For example:
- </p>
- <div class="code">
- <pre>
- %warnfilter(501) Object;
- class Object {
- public:
- ... // All 501 warnings ignored in class
- };
- </pre>
- </div>
- <p>
- There is no option to suppress all SWIG warning messages. The warning messages are there
- for a reason---to tell you that something may be <em>broken</em> in
- your interface. Ignore the warning messages at your own peril.
- </p>
- <H2><a name="Warnings_nn4"></a>14.3 Enabling extra warnings</H2>
- <p>
- Some warning messages are disabled by default and are generated only
- to provide additional diagnostics. These warnings can be turned on using the
- <tt>-Wextra</tt> option. For example:
- </p>
- <div class="shell">
- <pre>
- % swig -Wextra -python example.i
- </pre>
- </div>
- <p>
- To selectively turn on extra warning messages, you can use the directives and options in the
- previous section--simply add a "+" to all warning numbers. For example:
- </p>
- <div class="shell">
- <pre>
- % swig -w+309,+452 example.i
- </pre>
- </div>
- <p>
- or in your interface file use either
- </p>
- <div class="code">
- <pre>
- #pragma SWIG nowarn=+309,+452
- </pre>
- </div>
- <p>
- or
- </p>
- <div class="code">
- <pre>
- %warnfilter(+309,+452) foo;
- </pre>
- </div>
- <p>
- Note: selective enabling of warnings with <tt>%warnfilter</tt> overrides any global settings you might have
- made using <tt>-w</tt> or <tt>#pragma</tt>.
- </p>
- <p>
- You can of course also enable all warnings and suppress a select few, for example:
- </p>
- <div class="shell">
- <pre>
- % swig -Wextra -w309,452 example.i
- </pre>
- </div>
- <p>
- The warnings on the right take precedence over the warnings on the left, so in the above example <tt>-Wextra</tt> adds numerous warnings including 452, but then <tt>-w309,452</tt> overrides this and so 452 is suppressesed.
- </p>
- <p>
- If you would like all warnings to appear, regardless of the warning filters used, then use the <tt>-Wall</tt> option.
- The <tt>-Wall</tt> option also turns on the extra warnings that <tt>-Wextra</tt> adds, however, it is subtely different.
- When <tt>-Wall</tt> is used, it also disables all other warning filters,
- that is, any warnings suppressed or added in <tt>%warnfilter</tt>, <tt>#pragma SWIG nowarn</tt>
- or the <tt>-w</tt> option.
- </p>
- <H2><a name="Warnings_nn5"></a>14.4 Issuing a warning message</H2>
- <p>
- Warning messages can be issued from an interface file using a number of directives. The
- <tt>%warn</tt> directive is the most simple:
- </p>
- <div class="code">
- <pre>
- %warn "900:This is your last warning!"
- </pre>
- </div>
- <p>
- All warning messages are optionally prefixed by the warning number to use. If you are generating
- your own warnings, make sure you don't use numbers defined in the table at the end of this section.
- </p>
- <p>
- The <tt>%ignorewarn</tt> directive is the same as <tt>%ignore</tt> except that it issues a
- warning message whenever a matching declaration is found. For example:
- </p>
- <div class="code">
- <pre>
- %ignorewarn("362:operator= ignored") operator=;
- </pre>
- </div>
- <p>
- Warning messages can be associated with typemaps using the
- <tt>warning</tt> attribute of a typemap declaration. For example:
- </p>
- <div class="code">
- <pre>
- %typemap(in, warning="901:You are really going to regret this usage of $1_type $1_name") blah * {
- ...
- }
- </pre>
- </div>
- <p>
- In this case, the warning message will be printed whenever the typemap is actually used and the <a href="Typemaps.html#Typemaps_special_variables">special variables</a> will be expanded as appropriate, for example:
- </p>
- <div class="shell">
- <pre>
- example.i:23: Warning 901: You are really going to regret this usage of blah * self
- example.i:24: Warning 901: You are really going to regret this usage of blah * stuff
- </pre>
- </div>
- <H2><a name="Warnings_symbolic_symbols"></a>14.5 Symbolic symbols</H2>
- <p>
- The <tt>swigwarn.swg</tt> file that is installed with SWIG contains symbol constants that could also be
- used in <tt>%warnfilter</tt> and <tt>#pragma SWIG nowarn</tt>.
- For example this file contains the following line:
- </p>
- <div class="code">
- <pre>
- %define SWIGWARN_TYPE_UNDEFINED_CLASS 401 %enddef
- </pre>
- </div>
- <p>
- so <tt>SWIGWARN_TYPE_UNDEFINED_CLASS</tt> could be used instead of 401, for example:
- </p>
- <div class="code">
- <pre>
- #pragma SWIG nowarn=SWIGWARN_TYPE_UNDEFINED_CLASS
- </pre>
- </div>
- <p>
- or
- </p>
- <div class="code">
- <pre>
- %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Foo;
- </pre>
- </div>
- <H2><a name="Warnings_nn6"></a>14.6 Commentary</H2>
- <p>
- The ability to suppress warning messages is really only provided for
- advanced users and is not recommended in normal use. You are advised
- to modify your interface to fix the problems highlighted by the warnings
- wherever possible instead of suppressing warnings.
- </p>
- <p>
- Certain types of SWIG problems are errors. These usually arise due to
- parsing errors (bad syntax) or semantic problems for which there is
- no obvious recovery. There is no mechanism for suppressing error
- messages.
- </p>
- <H2><a name="Warnings_nn7"></a>14.7 Warnings as errors</H2>
- <p>
- Warnings can be handled as errors by using the <tt>-Werror</tt> command line
- option. This will cause SWIG to exit with a non successful exit code if a
- warning is encountered.
- </p>
- <H2><a name="Warnings_nn8"></a>14.8 Message output format</H2>
- <p>
- The output format for both warnings and errors can be selected for
- integration with your favourite IDE/editor. Editors and IDEs can usually parse
- error messages and if in the appropriate format will easily take you
- directly to the source of the error. The standard format is used by
- default except on Windows where the Microsoft format is used by default.
- These can be overridden using command line options, for example:
- </p>
- <div class="shell"><pre>
- $ swig -python -Fstandard example.i
- example.i:4: Syntax error in input.
- $ swig -python -Fmicrosoft example.i
- example.i(4) : Syntax error in input.
- </pre></div>
- <H2><a name="Warnings_nn9"></a>14.9 Warning number reference</H2>
- <H3><a name="Warnings_nn10"></a>14.9.1 Deprecated features (100-199)</H3>
- <ul>
- <li>101. Deprecated <tt>%extern</tt> directive.
- <li>102. Deprecated <tt>%val</tt> directive.
- <li>103. Deprecated <tt>%out</tt> directive.
- <li>104. Deprecated <tt>%disabledoc</tt> directive.
- <li>105. Deprecated <tt>%enabledoc</tt> directive.
- <li>106. Deprecated <tt>%doconly</tt> directive.
- <li>107. Deprecated <tt>%style</tt> directive.
- <li>108. Deprecated <tt>%localstyle</tt> directive.
- <li>109. Deprecated <tt>%title</tt> directive.
- <li>110. Deprecated <tt>%section</tt> directive.
- <li>111. Deprecated <tt>%subsection</tt> directive.
- <li>112. Deprecated <tt>%subsubsection</tt> directive.
- <li>113. Deprecated <tt>%addmethods</tt> directive.
- <li>114. Deprecated <tt>%readonly</tt> directive.
- <li>115. Deprecated <tt>%readwrite</tt> directive.
- <li>116. Deprecated <tt>%except</tt> directive.
- <li>117. Deprecated <tt>%new</tt> directive.
- <li>118. Deprecated <tt>%typemap(except)</tt>.
- <li>119. Deprecated <tt>%typemap(ignore)</tt>.
- <li>120. Deprecated command line option (-runtime, -noruntime).
- <li>121. Deprecated <tt>%name</tt> directive.
- </ul>
- <H3><a name="Warnings_nn11"></a>14.9.2 Preprocessor (200-299)</H3>
- <ul>
- <li>201. Unable to find <em>filename</em>.
- <li>202. Could not evaluate expression <em>expr</em>.
- <li>203. Both includeall and importall are defined: using includeall.
- <li>204. CPP #warning, "<em>warning</em>".
- <li>205. CPP #error, "<em>error</em>".
- <li>206. Unexpected tokens after #<em>directive</em> directive.
- </ul>
- <H3><a name="Warnings_nn12"></a>14.9.3 C/C++ Parser (300-399)</H3>
- <ul>
- <li>301. <tt>class</tt> keyword used, but not in C++ mode.
- <li>302. Identifier '<em>name</em>' redefined (ignored).
- <li>303. <tt>%extend</tt> defined for an undeclared class '<em>name</em>'.
- <li>304. Unsupported constant value (ignored).
- <li>305. Bad constant value (ignored).
- <li>306. '<em>identifier</em>' is private in this context.
- <li>307. Can't set default argument value (ignored)
- <li>308. Namespace alias '<em>name</em>' not allowed here. Assuming '<em>name</em>'
- <li>309. [private | protected] inheritance ignored.
- <li>310. Template '<em>name</em>' was already wrapped as '<em>name</em>' (ignored)
- <li>312. Unnamed nested class not currently supported (ignored).
- <li>313. Unrecognized extern type "<em>name</em>" (ignored).
- <li>314. '<em>identifier</em>' is a <em>lang</em> keyword.
- <li>315. Nothing known about '<em>identifier</em>'.
- <li>316. Repeated %module directive.
- <li>317. Specialization of non-template '<em>name</em>'.
- <li>318. Instantiation of template '<em>name</em>' is ambiguous, instantiation <em>templ</em> used, instantiation <em>templ</em> ignored.
- <li>319. No access specifier given for base class <em>name</em> (ignored).
- <li>320. Explicit template instantiation ignored.
- <li>321. <em>identifier</em> conflicts with a built-in name.
- <li>322. Redundant redeclaration of '<em>name</em>'.
- <li>323. Recursive scope inheritance of '<em>name</em>'.
- <li>324. Named nested template instantiations not supported. Processing as if no name was given to %template().
- <li>325. Nested class not currently supported (<em>name</em> ignored).
- <li>350. operator new ignored.
- <li>351. operator delete ignored.
- <li>352. operator+ ignored.
- <li>353. operator- ignored.
- <li>354. operator* ignored.
- <li>355. operator/ ignored.
- <li>356. operator% ignored.
- <li>357. operator^ ignored.
- <li>358. operator& ignored.
- <li>359. operator| ignored.
- <li>360. operator~ ignored.
- <li>361. operator! ignored.
- <li>362. operator= ignored.
- <li>363. operator< ignored.
- <li>364. operator> ignored.
- <li>365. operator+= ignored.
- <li>366. operator-= ignored.
- <li>367. operator*= ignored.
- <li>368. operator/= ignored.
- <li>369. operator%= ignored.
- <li>370. operator^= ignored.
- <li>371. operator&= ignored.
- <li>372. operator|= ignored.
- <li>373. operator<< ignored.
- <li>374. operator>>ignored.
- <li>375. operator<<= ignored.
- <li>376. operator>>= ignored.
- <li>377. operator== ignored.
- <li>378. operator!= ignored.
- <li>379. operator<= ignored.
- <li>380. operator>= ignored.
- <li>381. operator&& ignored.
- <li>382. operator|| ignored.
- <li>383. operator++ ignored.
- <li>384. operator-- ignored.
- <li>385. operator, ignored.
- <li>386. operator-<* ignored.
- <li>387. operator-< ignored.
- <li>388. operator() ignored.
- <li>389. operator[] ignored.
- <li>390. operator+ ignored (unary).
- <li>391. operator- ignored (unary).
- <li>392. operator* ignored (unary).
- <li>393. operator& ignored (unary).
- <li>394. operator new[] ignored.
- <li>395. operator delete[] ignored.
- </ul>
- <H3><a name="Warnings_nn13"></a>14.9.4 Types and typemaps (400-499) </H3>
- <ul>
- <li>401. Nothing known about class 'name'. Ignored.
- <li>402. Base class 'name' is incomplete.
- <li>403. Class 'name' might be abstract.
- <li>450. Deprecated typemap feature ($source/$target).
- <li>451. Setting const char * variable may leak memory.
- <li>452. Reserved
- <li>453. Can't apply (pattern). No typemaps are defined.
- <li>460. Unable to use type <em>type</em> as a function argument.
- <li>461. Unable to use return type <em>type</em> in function <em>name</em>.
- <li>462. Unable to set variable of type <em>type</em>.
- <li>463. Unable to read variable of type <em>type</em>.
- <li>464. Unsupported constant value.
- <li>465. Unable to handle type <em>type</em>.
- <li>466. Unsupported variable type <em>type</em>.
- <li>467. Overloaded <em>declaration</em> not supported (no type checking rule for '<em>type</em>')
- <li>468. No 'throw' typemap defined for exception type <em>type</em>
- <li>469. No or improper directorin typemap defined for <em>type</em>
- <li>470. Thread/reentrant unsafe wrapping, consider returning by value instead.
- <li>471. Unable to use return type <em>type</em> in director method
- <li>474. Method <em>method</em> usage of the optimal attribute ignored in the out typemap as the following cannot be used to generate optimal code: <em>code</em>
- <li>475. Multiple calls to <em>method</em> might be generated due to optimal attribute usage in the out typemap.
- </ul>
- <H3><a name="Warnings_nn14"></a>14.9.5 Code generation (500-599)</H3>
- <ul>
- <li>501. Overloaded declaration ignored. <em>decl</em>. Previous declaration is <em>decl</em>.
- <li>502. Overloaded constructor ignored. <em>decl</em>. Previous declaration is <em>decl</em>.
- <li>503. Can't wrap '<em>identifier</em>' unless renamed to a valid identifier.
- <li>504. Function <em>name</em> must have a return type. Ignored.
- <li>505. Variable length arguments discarded.
- <li>506. Can't wrap varargs with keyword arguments enabled.
- <li>507. Adding native function <em>name</em> not supported (ignored).
- <li>508. Declaration of '<em>name</em>' shadows declaration accessible via operator->(), previous declaration of'<em>declaration</em>'.
- <li>509. Overloaded method <em>declaration</em> effectively ignored, as it is shadowed by <em>declaration</em>.
- <li>510. Friend function '<em>name</em>' ignored.
- <li>511. Can't use keyword arguments with overloaded functions.
- <li>512. Overloaded method <em>declaration</em> ignored, using non-const method <em>declaration</em> instead.
- <li>513. Can't generate wrappers for unnamed struct/class.
- <li>514.
- <li>515.
- <li>516. Overloaded method <em>declaration</em> ignored, using <em>declaration</em> instead.
- <li>517.
- <li>518. Portability warning: File <em>file1</em> will be overwritten by <em>file2</em> on case insensitive filesystems such as Windows' FAT32 and NTFS unless the class/module name is renamed.
- <li>519. %template() contains no name. Template method ignored: <em>declaration</em>
- <li>520. <em>Base/Derived</em> class '<em>classname1</em>' of '<em>classname2</em>' is not similarly marked as a smart pointer.
- <li>521. Illegal destructor name <em>name</em>. Ignored.
- </ul>
- <H3><a name="Warnings_nn15"></a>14.9.6 Language module specific (700-899) </H3>
- <ul>
- <li>801. Wrong name (corrected to '<em>name</em>'). (Ruby).
- </ul>
- <ul>
- <li>810. No jni typemap defined for <em>type</em> (Java).
- <li>811. No jtype typemap defined for <em>type</em> (Java).
- <li>812. No jstype typemap defined for <em>type</em> (Java).
- <li>813. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in Java. (Java).
- <li>814.
- <li>815. No javafinalize typemap defined for <em>type</em> (Java).
- <li>816. No javabody typemap defined for <em>type</em> (Java).
- <li>817. No javaout typemap defined for <em>type</em> (Java).
- <li>818. No javain typemap defined for <em>type</em> (Java).
- <li>819. No javadirectorin typemap defined for <em>type</em> (Java).
- <li>820. No javadirectorout typemap defined for <em>type</em> (Java).
- <li>821.
- <li>822. Covariant return types not supported in Java. Proxy method will return <em>basetype</em> (Java).
- <li>823. No javaconstruct typemap defined for <em>type</em> (Java).
- <li>824. Missing JNI descriptor in directorin typemap defined for <em>type</em> (Java).
- </ul>
- <ul>
- <li>830. No ctype typemap defined for <em>type</em> (C#).
- <li>831. No cstype typemap defined for <em>type</em> (C#).
- <li>832. No cswtype typemap defined for <em>type</em> (C#).
- <li>833. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in C#. (C#).
- <li>834.
- <li>835. No csfinalize typemap defined for <em>type</em> (C#).
- <li>836. No csbody typemap defined for <em>type</em> (C#).
- <li>837. No csout typemap defined for <em>type</em> (C#).
- <li>838. No csin typemap defined for <em>type</em> (C#).
- <li>839.
- <li>840.
- <li>841.
- <li>842. Covariant return types not supported in C#. Proxy method will return <em>basetype</em> (C#).
- <li>843. No csconstruct typemap defined for <em>type</em> (C#).
- <li>844. C# exception may not be thrown - no $excode or excode attribute in <em>typemap</em> typemap. (C#).
- <li>845. Unmanaged code contains a call to a SWIG_CSharpSetPendingException method and C# code does not handle pending exceptions via the canthrow attribute. (C#).
- </ul>
- <ul>
- <li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in PHP.
- <li>871. Unrecognized pragma <em>pragma</em>. (Php).
- </ul>
- <H3><a name="Warnings_nn16"></a>14.9.7 User defined (900-999)</H3>
- <p>
- These numbers can be used by your own application.
- </p>
- <H2><a name="Warnings_nn17"></a>14.10 History</H2>
- <p>
- The ability to control warning messages was first added to SWIG-1.3.12.
- </p>
- </body>
- </html>