1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <title>Warning Messages</title>
5 <link rel="stylesheet" type="text/css" href="style.css">
8 <body bgcolor="#ffffff">
9 <H1><a name="Warnings"></a>14 Warning Messages</H1>
11 <div class="sectiontoc">
13 <li><a href="#Warnings_nn2">Introduction</a>
14 <li><a href="#Warnings_suppression">Warning message suppression</a>
15 <li><a href="#Warnings_nn4">Enabling extra warnings</a>
16 <li><a href="#Warnings_nn5">Issuing a warning message</a>
17 <li><a href="#Warnings_symbolic_symbols">Symbolic symbols</a>
18 <li><a href="#Warnings_nn6">Commentary</a>
19 <li><a href="#Warnings_nn7">Warnings as errors</a>
20 <li><a href="#Warnings_nn8">Message output format</a>
21 <li><a href="#Warnings_nn9">Warning number reference</a>
23 <li><a href="#Warnings_nn10">Deprecated features (100-199)</a>
24 <li><a href="#Warnings_nn11">Preprocessor (200-299)</a>
25 <li><a href="#Warnings_nn12">C/C++ Parser (300-399)</a>
26 <li><a href="#Warnings_nn13">Types and typemaps (400-499) </a>
27 <li><a href="#Warnings_nn14">Code generation (500-599)</a>
28 <li><a href="#Warnings_nn15">Language module specific (800-899) </a>
29 <li><a href="#Warnings_nn16">User defined (900-999)</a>
31 <li><a href="#Warnings_nn17">History</a>
38 <H2><a name="Warnings_nn2"></a>14.1 Introduction</H2>
42 During compilation, SWIG may generate a variety of warning messages. For example:
47 example.i:16: Warning(501): Overloaded declaration ignored. bar(double)
48 example.i:15: Warning(501): Previous declaration is bar(int)
53 Typically, warning messages indicate non-fatal problems with the input
54 where the generated wrapper code will probably compile, but it may not
58 <H2><a name="Warnings_suppression"></a>14.2 Warning message suppression</H2>
62 All warning messages have a numeric code that is shown in the warning message itself.
63 To suppress the printing of a warning message, a number of techniques can be used.
64 First, you can run SWIG with the <tt>-w</tt> command line option. For example:
69 % swig -python -w501 example.i
70 % swig -python -w501,505,401 example.i
75 Alternatively, warnings can be suppressed by inserting a special preprocessor pragma
82 #pragma SWIG nowarn=501
83 #pragma SWIG nowarn=501,505,401
88 Finally, code-generation warnings can be disabled on a declaration by declaration basis using
89 the <tt>%warnfilter</tt> directive. For example:
98 int foo(double); // Silently ignored.
103 The <tt>%warnfilter</tt> directive has the same semantics as other declaration modifiers like
104 <tt>%rename</tt>, <tt>%ignore</tt> and <tt>%feature</tt>, see the
105 <a href="Customization.html#features">%feature directive</a> section. For example, if you wanted to
106 suppress a warning for a method in a class hierarchy, you could do this:
111 %warnfilter(501) Object::foo;
115 int foo(double); // Silently ignored
119 class Derived : public Object {
122 int foo(double); // Silently ignored
129 Warnings can be suppressed for an entire class by supplying a class name. For example:
134 %warnfilter(501) Object;
138 ... // All 501 warnings ignored in class
144 There is no option to suppress all SWIG warning messages. The warning messages are there
145 for a reason---to tell you that something may be <em>broken</em> in
146 your interface. Ignore the warning messages at your own peril.
150 <H2><a name="Warnings_nn4"></a>14.3 Enabling extra warnings</H2>
154 Some warning messages are disabled by default and are generated only
155 to provide additional diagnostics. These warnings can be turned on using the
156 <tt>-Wextra</tt> option. For example:
161 % swig -Wextra -python example.i
166 To selectively turn on extra warning messages, you can use the directives and options in the
167 previous section--simply add a "+" to all warning numbers. For example:
172 % swig -w+309,+452 example.i
177 or in your interface file use either
182 #pragma SWIG nowarn=+309,+452
192 %warnfilter(+309,+452) foo;
197 Note: selective enabling of warnings with <tt>%warnfilter</tt> overrides any global settings you might have
198 made using <tt>-w</tt> or <tt>#pragma</tt>.
202 You can of course also enable all warnings and suppress a select few, for example:
207 % swig -Wextra -w309,452 example.i
212 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.
216 If you would like all warnings to appear, regardless of the warning filters used, then use the <tt>-Wall</tt> option.
217 The <tt>-Wall</tt> option also turns on the extra warnings that <tt>-Wextra</tt> adds, however, it is subtely different.
218 When <tt>-Wall</tt> is used, it also disables all other warning filters,
219 that is, any warnings suppressed or added in <tt>%warnfilter</tt>, <tt>#pragma SWIG nowarn</tt>
220 or the <tt>-w</tt> option.
223 <H2><a name="Warnings_nn5"></a>14.4 Issuing a warning message</H2>
227 Warning messages can be issued from an interface file using a number of directives. The
228 <tt>%warn</tt> directive is the most simple:
233 %warn "900:This is your last warning!"
238 All warning messages are optionally prefixed by the warning number to use. If you are generating
239 your own warnings, make sure you don't use numbers defined in the table at the end of this section.
243 The <tt>%ignorewarn</tt> directive is the same as <tt>%ignore</tt> except that it issues a
244 warning message whenever a matching declaration is found. For example:
249 %ignorewarn("362:operator= ignored") operator=;
254 Warning messages can be associated with typemaps using the
255 <tt>warning</tt> attribute of a typemap declaration. For example:
260 %typemap(in, warning="901:You are really going to regret this") blah * {
267 In this case, the warning message will be printed whenever the typemap is actually used.
270 <H2><a name="Warnings_symbolic_symbols"></a>14.5 Symbolic symbols</H2>
274 The <tt>swigwarn.swg</tt> file that is installed with SWIG contains symbol constants that could also be
275 used in <tt>%warnfilter</tt> and <tt>#pragma SWIG nowarn</tt>.
276 For example this file contains the following line:
281 %define SWIGWARN_TYPE_UNDEFINED_CLASS 401 %enddef
286 so <tt>SWIGWARN_TYPE_UNDEFINED_CLASS</tt> could be used instead of 401, for example:
291 #pragma SWIG nowarn=SWIGWARN_TYPE_UNDEFINED_CLASS
301 %warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Foo;
305 <H2><a name="Warnings_nn6"></a>14.6 Commentary</H2>
309 The ability to suppress warning messages is really only provided for
310 advanced users and is not recommended in normal use. You are advised
311 to modify your interface to fix the problems highlighted by the warnings
312 wherever possible instead of suppressing warnings.
316 Certain types of SWIG problems are errors. These usually arise due to
317 parsing errors (bad syntax) or semantic problems for which there is
318 no obvious recovery. There is no mechanism for suppressing error
322 <H2><a name="Warnings_nn7"></a>14.7 Warnings as errors</H2>
326 Warnings can be handled as errors by using the <tt>-Werror</tt> command line
327 option. This will cause SWIG to exit with a non successful exit code if a
328 warning is encountered.
331 <H2><a name="Warnings_nn8"></a>14.8 Message output format</H2>
335 The output format for both warnings and errors can be selected for
336 integration with your favourite IDE/editor. Editors and IDEs can usually parse
337 error messages and if in the appropriate format will easily take you
338 directly to the source of the error. The standard format is used by
339 default except on Windows where the Microsoft format is used by default.
340 These can be overridden using command line options, for example:
343 <div class="shell"><pre>
344 $ swig -python -Fstandard example.i
345 example.i:4: Syntax error in input.
346 $ swig -python -Fmicrosoft example.i
347 example.i(4): Syntax error in input.
350 <H2><a name="Warnings_nn9"></a>14.9 Warning number reference</H2>
353 <H3><a name="Warnings_nn10"></a>14.9.1 Deprecated features (100-199)</H3>
357 <li>101. Deprecated <tt>%extern</tt> directive.
358 <li>102. Deprecated <tt>%val</tt> directive.
359 <li>103. Deprecated <tt>%out</tt> directive.
360 <li>104. Deprecated <tt>%disabledoc</tt> directive.
361 <li>105. Deprecated <tt>%enabledoc</tt> directive.
362 <li>106. Deprecated <tt>%doconly</tt> directive.
363 <li>107. Deprecated <tt>%style</tt> directive.
364 <li>108. Deprecated <tt>%localstyle</tt> directive.
365 <li>109. Deprecated <tt>%title</tt> directive.
366 <li>110. Deprecated <tt>%section</tt> directive.
367 <li>111. Deprecated <tt>%subsection</tt> directive.
368 <li>112. Deprecated <tt>%subsubsection</tt> directive.
369 <li>113. Deprecated <tt>%addmethods</tt> directive.
370 <li>114. Deprecated <tt>%readonly</tt> directive.
371 <li>115. Deprecated <tt>%readwrite</tt> directive.
372 <li>116. Deprecated <tt>%except</tt> directive.
373 <li>117. Deprecated <tt>%new</tt> directive.
374 <li>118. Deprecated <tt>%typemap(except)</tt>.
375 <li>119. Deprecated <tt>%typemap(ignore)</tt>.
376 <li>120. Deprecated command line option (-runtime, -noruntime).
377 <li>121. Deprecated <tt>%name</tt> directive.
380 <H3><a name="Warnings_nn11"></a>14.9.2 Preprocessor (200-299)</H3>
384 <li>201. Unable to find 'filename'.
385 <li>202. Could not evaluate 'expr'.
388 <H3><a name="Warnings_nn12"></a>14.9.3 C/C++ Parser (300-399)</H3>
392 <li>301. <tt>class</tt> keyword used, but not in C++ mode.
393 <li>302. Identifier '<em>name</em>' redefined (ignored).
394 <li>303. <tt>%extend</tt> defined for an undeclared class '<em>name</em>'.
395 <li>304. Unsupported constant value (ignored).
396 <li>305. Bad constant value (ignored).
397 <li>306. '<em>identifier</em>' is private in this context.
398 <li>307. Can't set default argument value (ignored)
399 <li>308. Namespace alias '<em>name</em>' not allowed here. Assuming '<em>name</em>'
400 <li>309. [private | protected] inheritance ignored.
401 <li>310. Template '<em>name</em>' was already wrapped as '<em>name</em>' (ignored)
402 <li>311. Template partial specialization not supported.
403 <li>312. Nested classes not currently supported (ignored).
404 <li>313. Unrecognized extern type "<em>name</em>" (ignored).
405 <li>314. '<em>identifier</em>' is a <em>lang</em> keyword.
406 <li>315. Nothing known about '<em>identifier</em>'.
407 <li>316. Repeated %module directive.
408 <li>317. Specialization of non-template '<em>name</em>'.
409 <li>318. Instantiation of template <em>name</em> is ambiguous. Using <em>templ</em> at <em>file</em>:<em>line</em>
410 <li>319. No access specifier given for base class <em>name</em> (ignored).
411 <li>320. Explicit template instantiation ignored.
412 <li>321. <em>identifier</em> conflicts with a built-in name.
413 <li>322. Redundant redeclaration of '<em>name</em>'.
414 <li>350. operator new ignored.
415 <li>351. operator delete ignored.
416 <li>352. operator+ ignored.
417 <li>353. operator- ignored.
418 <li>354. operator* ignored.
419 <li>355. operator/ ignored.
420 <li>356. operator% ignored.
421 <li>357. operator^ ignored.
422 <li>358. operator& ignored.
423 <li>359. operator| ignored.
424 <li>360. operator~ ignored.
425 <li>361. operator! ignored.
426 <li>362. operator= ignored.
427 <li>363. operator< ignored.
428 <li>364. operator> ignored.
429 <li>365. operator+= ignored.
430 <li>366. operator-= ignored.
431 <li>367. operator*= ignored.
432 <li>368. operator/= ignored.
433 <li>369. operator%= ignored.
434 <li>370. operator^= ignored.
435 <li>371. operator&= ignored.
436 <li>372. operator|= ignored.
437 <li>373. operator<< ignored.
438 <li>374. operator>>ignored.
439 <li>375. operator<<= ignored.
440 <li>376. operator>>= ignored.
441 <li>377. operator== ignored.
442 <li>378. operator!= ignored.
443 <li>379. operator<= ignored.
444 <li>380. operator>= ignored.
445 <li>381. operator&& ignored.
446 <li>382. operator|| ignored.
447 <li>383. operator++ ignored.
448 <li>384. operator-- ignored.
449 <li>385. operator, ignored.
450 <li>386. operator-<* ignored.
451 <li>387. operator-< ignored.
452 <li>388. operator() ignored.
453 <li>389. operator[] ignored.
454 <li>390. operator+ ignored (unary).
455 <li>391. operator- ignored (unary).
456 <li>392. operator* ignored (unary).
457 <li>393. operator& ignored (unary).
458 <li>394. operator new[] ignored.
459 <li>395. operator delete[] ignored.
462 <H3><a name="Warnings_nn13"></a>14.9.4 Types and typemaps (400-499) </H3>
466 <li>401. Nothing known about class 'name'. Ignored.
467 <li>402. Base class 'name' is incomplete.
468 <li>403. Class 'name' might be abstract.
469 <li>450. Deprecated typemap feature ($source/$target).
470 <li>451. Setting const char * variable may leak memory.
472 <li>453. Can't apply (pattern). No typemaps are defined.
473 <li>460. Unable to use type <em>type</em> as a function argument.
474 <li>461. Unable to use return type <em>type</em> in function <em>name</em>.
475 <li>462. Unable to set variable of type <em>type</em>.
476 <li>463. Unable to read variable of type <em>type</em>.
477 <li>464. Unsupported constant value.
478 <li>465. Unable to handle type <em>type</em>.
479 <li>466. Unsupported variable type <em>type</em>.
480 <li>467. Overloaded <em>declaration</em> not supported (no type checking rule for '<em>type</em>')
481 <li>468. No 'throw' typemap defined for exception type <em>type</em>
482 <li>469. No or improper directorin typemap defined for <em>type</em>
483 <li>470. Thread/reentrant unsafe wrapping, consider returning by value instead.
484 <li>471. Unable to use return type <em>type</em> in director method
485 <li>474. Method <em>method</em> usage of the optimal attribute in the out typemap at <em>file</em>:<em>line</em> ignored as the following cannot be used to generate optimal code: <em>code</em>
486 <li>475. Multiple calls to <em>method</em> might be generated due to optimal attribute usage in the out typemap at <em>file</em>:<em>line</em>.
491 <H3><a name="Warnings_nn14"></a>14.9.5 Code generation (500-599)</H3>
495 <li>501. Overloaded declaration ignored. <em>decl</em>
496 <li>502. Overloaded constructor ignored. <em>decl</em>
497 <li>503. Can't wrap '<em>identifier</em>' unless renamed to a valid identifier.
498 <li>504. Function <em>name</em> must have a return type.
499 <li>505. Variable length arguments discarded.
500 <li>506. Can't wrap varargs with keyword arguments enabled.
501 <li>507. Adding native function <em>name</em> not supported (ignored).
502 <li>508. Declaration of '<em>name</em>' shadows declaration accessible via operator->() at <em>file:line</em>.
503 <li>509. Overloaded <em>declaration</em> is shadowed by <em>declaration</em> at <em>file</em>:<em>line</em>.
504 <li>510. Friend function '<em>name</em>' ignored.
505 <li>511. Can't use keyword arguments with overloaded functions.
506 <li>512. Overloaded <em>declaration</em> const ignored. Non-const method at <em>file</em>:<em>line</em> used.
507 <li>513. Can't generate wrappers for unnamed struct/class.
510 <li>516. Overloaded method <em>declaration</em> ignored. Method <em>declaration</em> at <em>file</em>:<em>line</em> used.
512 <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.
513 <li>519. %template() contains no name. Template method ignored: <em>declaration</em>
516 <H3><a name="Warnings_nn15"></a>14.9.6 Language module specific (800-899) </H3>
520 <li>801. Wrong name (corrected to '<em>name</em>'). (Ruby).
524 <li>810. No jni typemap defined for <em>type</em> (Java).
525 <li>811. No jtype typemap defined for <em>type</em> (Java).
526 <li>812. No jstype typemap defined for <em>type</em> (Java).
527 <li>813. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in Java. (Java).
529 <li>815. No javafinalize typemap defined for <em>type</em> (Java).
530 <li>816. No javabody typemap defined for <em>type</em> (Java).
531 <li>817. No javaout typemap defined for <em>type</em> (Java).
532 <li>818. No javain typemap defined for <em>type</em> (Java).
533 <li>819. No javadirectorin typemap defined for <em>type</em> (Java).
534 <li>820. No javadirectorout typemap defined for <em>type</em> (Java).
536 <li>822. Covariant return types not supported in Java. Proxy method will return <em>basetype</em> (Java).
537 <li>823. No javaconstruct typemap defined for <em>type</em> (Java).
538 <li>824. Missing JNI descriptor in directorin typemap defined for <em>type</em> (Java).
542 <li>830. No ctype typemap defined for <em>type</em> (C#).
543 <li>831. No cstype typemap defined for <em>type</em> (C#).
544 <li>832. No cswtype typemap defined for <em>type</em> (C#).
545 <li>833. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in C#. (C#).
547 <li>835. No csfinalize typemap defined for <em>type</em> (C#).
548 <li>836. No csbody typemap defined for <em>type</em> (C#).
549 <li>837. No csout typemap defined for <em>type</em> (C#).
550 <li>838. No csin typemap defined for <em>type</em> (C#).
554 <li>842. Covariant return types not supported in C#. Proxy method will return <em>basetype</em> (C#).
555 <li>843. No csconstruct typemap defined for <em>type</em> (C#).
556 <li>844. C# exception may not be thrown - no $excode or excode attribute in <em>typemap</em> typemap. (C#).
557 <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#).
561 <li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in PHP.
562 <li>871. Unrecognized pragma <em>pragma</em>. (Php).
565 <H3><a name="Warnings_nn16"></a>14.9.7 User defined (900-999)</H3>
569 These numbers can be used by your own application.
572 <H2><a name="Warnings_nn17"></a>14.10 History</H2>
576 The ability to control warning messages was first added to SWIG-1.3.12.