Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <title>Warning Messages</title> | |
5 | <link rel="stylesheet" type="text/css" href="style.css"> | |
6 | </head> | |
7 | ||
8 | <body bgcolor="#ffffff"> | |
9 | <H1><a name="Warnings"></a>14 Warning Messages</H1> | |
10 | <!-- INDEX --> | |
11 | <div class="sectiontoc"> | |
12 | <ul> | |
13 | <li><a href="#Warnings_nn2">Introduction</a> | |
14 | <li><a href="#Warnings_nn3">Warning message suppression</a> | |
15 | <li><a href="#Warnings_nn4">Enabling additional warnings</a> | |
16 | <li><a href="#Warnings_nn5">Issuing a warning message</a> | |
17 | <li><a href="#Warnings_nn6">Commentary</a> | |
18 | <li><a href="#Warnings_nn7">Warnings as errors</a> | |
19 | <li><a href="#Warnings_nn8">Message output format</a> | |
20 | <li><a href="#Warnings_nn9">Warning number reference</a> | |
21 | <ul> | |
22 | <li><a href="#Warnings_nn10">Deprecated features (100-199)</a> | |
23 | <li><a href="#Warnings_nn11">Preprocessor (200-299)</a> | |
24 | <li><a href="#Warnings_nn12">C/C++ Parser (300-399)</a> | |
25 | <li><a href="#Warnings_nn13">Types and typemaps (400-499) </a> | |
26 | <li><a href="#Warnings_nn14">Code generation (500-599)</a> | |
27 | <li><a href="#Warnings_nn15">Language module specific (800-899) </a> | |
28 | <li><a href="#Warnings_nn16">User defined (900-999)</a> | |
29 | </ul> | |
30 | <li><a href="#Warnings_nn17">History</a> | |
31 | </ul> | |
32 | </div> | |
33 | <!-- INDEX --> | |
34 | ||
35 | ||
36 | ||
37 | <H2><a name="Warnings_nn2"></a>14.1 Introduction</H2> | |
38 | ||
39 | ||
40 | <p> | |
41 | During compilation, SWIG may generate a variety of warning messages. For example: | |
42 | </p> | |
43 | ||
44 | <div class="shell"> | |
45 | <pre> | |
46 | example.i:16: Warning(501): Overloaded declaration ignored. bar(double) | |
47 | example.i:15: Warning(501): Previous declaration is bar(int) | |
48 | </pre> | |
49 | </div> | |
50 | ||
51 | <p> | |
52 | Typically, warning messages indicate non-fatal problems with the input | |
53 | where the generated wrapper code will probably compile, but it may not | |
54 | work like you expect. | |
55 | </p> | |
56 | ||
57 | <H2><a name="Warnings_nn3"></a>14.2 Warning message suppression</H2> | |
58 | ||
59 | ||
60 | <p> | |
61 | All warning messages have a numeric code that is shown in the warning message itself. | |
62 | To suppress the printing of a warning message, a number of techniques can be used. | |
63 | First, you can run SWIG with the <tt>-w</tt> command line option. For example: | |
64 | </p> | |
65 | ||
66 | <div class="shell"> | |
67 | <pre> | |
68 | % swig -python -w501 example.i | |
69 | % swig -python -w501,505,401 example.i | |
70 | </pre> | |
71 | </div> | |
72 | ||
73 | <p> | |
74 | Alternatively, warnings can be suppressed by inserting a special preprocessor pragma | |
75 | into the input file: | |
76 | </p> | |
77 | ||
78 | <div class="code"> | |
79 | <pre> | |
80 | %module example | |
81 | #pragma SWIG nowarn=501 | |
82 | #pragma SWIG nowarn=501,505,401 | |
83 | </pre> | |
84 | </div> | |
85 | ||
86 | <p> | |
87 | Finally, code-generation warnings can be disabled on a declaration by declaration basis using | |
88 | the <tt>%warnfilter</tt> directive. For example: | |
89 | </p> | |
90 | ||
91 | <div class="code"> | |
92 | <pre> | |
93 | %module example | |
94 | %warnfilter(501) foo; | |
95 | ... | |
96 | int foo(int); | |
97 | int foo(double); // Silently ignored. | |
98 | </pre> | |
99 | </div> | |
100 | ||
101 | <p> | |
102 | The <tt>%warnfilter</tt> directive has the same semantics as other declaration modifiers like | |
103 | <tt>%rename</tt>, <tt>%ignore</tt>, and <tt>%feature</tt>. For example, if you wanted to | |
104 | suppress a warning for a method in a class hierarchy, you could do this: | |
105 | </p> | |
106 | ||
107 | <div class="code"> | |
108 | <pre> | |
109 | %warnfilter(501) Object::foo; | |
110 | class Object { | |
111 | public: | |
112 | int foo(int); | |
113 | int foo(double); // Silently ignored | |
114 | ... | |
115 | }; | |
116 | ||
117 | class Derived : public Object { | |
118 | public: | |
119 | int foo(int); | |
120 | int foo(double); // Silently ignored | |
121 | ... | |
122 | }; | |
123 | </pre> | |
124 | </div> | |
125 | ||
126 | <p> | |
127 | Warnings can be suppressed for an entire class by supplying a class name. For example: | |
128 | </p> | |
129 | ||
130 | <div class="code"> | |
131 | <pre> | |
132 | %warnfilter(501) Object; | |
133 | ||
134 | class Object { | |
135 | public: | |
136 | ... // All 501 warnings ignored in class | |
137 | }; | |
138 | </pre> | |
139 | </div> | |
140 | ||
141 | <p> | |
142 | There is no option to suppress all SWIG warning messages. The warning messages are there | |
143 | for a reason---to tell you that something may be <em>broken</em> in | |
144 | your interface. Ignore the warning messages at your own peril. | |
145 | </p> | |
146 | ||
147 | <H2><a name="Warnings_nn4"></a>14.3 Enabling additional warnings</H2> | |
148 | ||
149 | ||
150 | <p> | |
151 | Some warning messages are disabled by default and are generated only | |
152 | to provide additional diagnostics. All warning messages can be | |
153 | enabled using the <tt>-Wall</tt> option. For example: | |
154 | </p> | |
155 | ||
156 | <div class="shell"> | |
157 | <pre> | |
158 | % swig -Wall -python example.i | |
159 | </pre> | |
160 | </div> | |
161 | ||
162 | <p> | |
163 | When <tt>-Wall</tt> is used, all other warning filters are disabled. | |
164 | </p> | |
165 | ||
166 | <p> | |
167 | To selectively turn on extra warning messages, you can use the directives and options in the | |
168 | previous section--simply add a "+" to all warning numbers. For example: | |
169 | </p> | |
170 | ||
171 | <div class="shell"> | |
172 | <pre> | |
173 | % swig -w+309,+452 example.i | |
174 | </pre> | |
175 | </div> | |
176 | ||
177 | <p> | |
178 | or | |
179 | </p> | |
180 | ||
181 | <div class="code"> | |
182 | <pre> | |
183 | #pragma SWIG nowarn=+309,+452 | |
184 | </pre> | |
185 | </div> | |
186 | ||
187 | <p> | |
188 | or | |
189 | </p> | |
190 | ||
191 | <div class="code"> | |
192 | <pre> | |
193 | %warnfilter(+309,+452) foo; | |
194 | </pre> | |
195 | </div> | |
196 | ||
197 | <p> | |
198 | Note: selective enabling of warnings with <tt>%warnfilter</tt> overrides any global settings you might have | |
199 | made using <tt>-w</tt> or <tt>#pragma</tt>. | |
200 | </p> | |
201 | ||
202 | <H2><a name="Warnings_nn5"></a>14.4 Issuing a warning message</H2> | |
203 | ||
204 | ||
205 | <p> | |
206 | Warning messages can be issued from an interface file using a number of directives. The | |
207 | <tt>%warn</tt> directive is the most simple: | |
208 | </p> | |
209 | ||
210 | <div class="code"> | |
211 | <pre> | |
212 | %warn "750:This is your last warning!" | |
213 | </pre> | |
214 | </div> | |
215 | ||
216 | <p> | |
217 | All warning messages are optionally prefixed by the warning number to use. If you are generating | |
218 | your own warnings, make sure you don't use numbers defined in the table at the end of this section. | |
219 | </p> | |
220 | ||
221 | <p> | |
222 | The <tt>%ignorewarn</tt> directive is the same as <tt>%ignore</tt> except that it issues a | |
223 | warning message whenever a matching declaration is found. For example: | |
224 | </p> | |
225 | ||
226 | <div class="code"> | |
227 | <pre> | |
228 | %ignorewarn("362:operator= ignored") operator=; | |
229 | </pre> | |
230 | </div> | |
231 | ||
232 | <p> | |
233 | Warning messages can be associated with typemaps using the | |
234 | <tt>warning</tt> attribute of a typemap declaration. For example: | |
235 | </p> | |
236 | ||
237 | <div class="code"> | |
238 | <pre> | |
239 | %typemap(in, warning="751:You are really going to regret this") blah * { | |
240 | ... | |
241 | } | |
242 | </pre> | |
243 | </div> | |
244 | ||
245 | <p> | |
246 | In this case, the warning message will be printed whenever the typemap is actually used. | |
247 | </p> | |
248 | ||
249 | <H2><a name="Warnings_nn6"></a>14.5 Commentary</H2> | |
250 | ||
251 | ||
252 | <p> | |
253 | The ability to suppress warning messages is really only provided for | |
254 | advanced users and is not recommended in normal use. There are no | |
255 | plans to provide symbolic names or options that identify specific | |
256 | types or groups of warning messages---the numbers must be used | |
257 | explicitly. | |
258 | </p> | |
259 | ||
260 | <p> | |
261 | Certain types of SWIG problems are errors. These usually arise due to | |
262 | parsing errors (bad syntax) or semantic problems for which there is | |
263 | no obvious recovery. There is no mechanism for suppressing error | |
264 | messages. | |
265 | </p> | |
266 | ||
267 | <H2><a name="Warnings_nn7"></a>14.6 Warnings as errors</H2> | |
268 | ||
269 | ||
270 | <p> | |
271 | Warnings can be handled as errors by using the <tt>-Werror</tt> command line | |
272 | option. This will cause SWIG to exit with a non successful exit code if a | |
273 | warning is encountered. | |
274 | </p> | |
275 | ||
276 | <H2><a name="Warnings_nn8"></a>14.7 Message output format</H2> | |
277 | ||
278 | ||
279 | <p> | |
280 | The output format for both warnings and errors can be selected for | |
281 | integration with your favourite IDE/editor. Editors and IDEs can usually parse | |
282 | error messages and if in the appropriate format will easily take you | |
283 | directly to the source of the error. The standard format is used by | |
284 | default except on Windows where the Microsoft format is used by default. | |
285 | These can be overridden using command line options, for example: | |
286 | </p> | |
287 | ||
288 | <div class="shell"><pre> | |
289 | $ swig -python -Fstandard example.i | |
290 | example.i:4: Syntax error in input. | |
291 | $ swig -python -Fmicrosoft example.i | |
292 | example.i(4): Syntax error in input. | |
293 | </pre></div> | |
294 | ||
295 | <H2><a name="Warnings_nn9"></a>14.8 Warning number reference</H2> | |
296 | ||
297 | ||
298 | <H3><a name="Warnings_nn10"></a>14.8.1 Deprecated features (100-199)</H3> | |
299 | ||
300 | ||
301 | <ul> | |
302 | <li>101. Deprecated <tt>%extern</tt> directive. | |
303 | <li>102. Deprecated <tt>%val</tt> directive. | |
304 | <li>103. Deprecated <tt>%out</tt> directive. | |
305 | <li>104. Deprecated <tt>%disabledoc</tt> directive. | |
306 | <li>105. Deprecated <tt>%enabledoc</tt> directive. | |
307 | <li>106. Deprecated <tt>%doconly</tt> directive. | |
308 | <li>107. Deprecated <tt>%style</tt> directive. | |
309 | <li>108. Deprecated <tt>%localstyle</tt> directive. | |
310 | <li>109. Deprecated <tt>%title</tt> directive. | |
311 | <li>110. Deprecated <tt>%section</tt> directive. | |
312 | <li>111. Deprecated <tt>%subsection</tt> directive. | |
313 | <li>112. Deprecated <tt>%subsubsection</tt> directive. | |
314 | <li>113. Deprecated <tt>%addmethods</tt> directive. | |
315 | <li>114. Deprecated <tt>%readonly</tt> directive. | |
316 | <li>115. Deprecated <tt>%readwrite</tt> directive. | |
317 | <li>116. Deprecated <tt>%except</tt> directive. | |
318 | <li>117. Deprecated <tt>%new</tt> directive. | |
319 | <li>118. Deprecated <tt>%typemap(except)</tt>. | |
320 | <li>119. Deprecated <tt>%typemap(ignore)</tt>. | |
321 | <li>120. Deprecated command line option (-c). | |
322 | <li>121. Deprecated <tt>%name</tt> directive. | |
323 | </ul> | |
324 | ||
325 | <H3><a name="Warnings_nn11"></a>14.8.2 Preprocessor (200-299)</H3> | |
326 | ||
327 | ||
328 | <ul> | |
329 | <li>201. Unable to find 'filename'. | |
330 | <li>202. Could not evaluate 'expr'. | |
331 | </ul> | |
332 | ||
333 | <H3><a name="Warnings_nn12"></a>14.8.3 C/C++ Parser (300-399)</H3> | |
334 | ||
335 | ||
336 | <ul> | |
337 | <li>301. <tt>class</tt> keyword used, but not in C++ mode. | |
338 | <li>302. Identifier '<em>name</em>' redefined (ignored). | |
339 | <li>303. <tt>%extend</tt> defined for an undeclared class '<em>name</em>'. | |
340 | <li>304. Unsupported constant value (ignored). | |
341 | <li>305. Bad constant value (ignored). | |
342 | <li>306. '<em>identifier</em>' is private in this context. | |
343 | <li>307. Can't set default argument value (ignored) | |
344 | <li>308. Namespace alias '<em>name</em>' not allowed here. Assuming '<em>name</em>' | |
345 | <li>309. [private | protected] inheritance ignored. | |
346 | <li>310. Template '<em>name</em>' was already wrapped as '<em>name</em>' (ignored) | |
347 | <li>311. Template partial specialization not supported. | |
348 | <li>312. Nested classes not currently supported (ignored). | |
349 | <li>313. Unrecognized extern type "<em>name</em>" (ignored). | |
350 | <li>314. '<em>identifier</em>' is a <em>lang</em> keyword. | |
351 | <li>315. Nothing known about '<em>identifier</em>'. | |
352 | <li>316. Repeated %module directive. | |
353 | <li>317. Specialization of non-template '<em>name</em>'. | |
354 | <li>318. Instantiation of template <em>name</em> is ambiguous. Using <em>templ</em> at <em>file</em>:<em>line</em> | |
355 | <li>319. No access specifier given for base class <em>name</em> (ignored). | |
356 | <li>320. Explicit template instantiation ignored. | |
357 | <li>321. <em>identifier</em> conflicts with a built-in name. | |
358 | <li>322. Redundant redeclaration of '<em>name</em>'. | |
359 | <li>350. operator new ignored. | |
360 | <li>351. operator delete ignored. | |
361 | <li>352. operator+ ignored. | |
362 | <li>353. operator- ignored. | |
363 | <li>354. operator* ignored. | |
364 | <li>355. operator/ ignored. | |
365 | <li>356. operator% ignored. | |
366 | <li>357. operator^ ignored. | |
367 | <li>358. operator& ignored. | |
368 | <li>359. operator| ignored. | |
369 | <li>360. operator~ ignored. | |
370 | <li>361. operator! ignored. | |
371 | <li>362. operator= ignored. | |
372 | <li>363. operator< ignored. | |
373 | <li>364. operator> ignored. | |
374 | <li>365. operator+= ignored. | |
375 | <li>366. operator-= ignored. | |
376 | <li>367. operator*= ignored. | |
377 | <li>368. operator/= ignored. | |
378 | <li>369. operator%= ignored. | |
379 | <li>370. operator^= ignored. | |
380 | <li>371. operator&= ignored. | |
381 | <li>372. operator|= ignored. | |
382 | <li>373. operator<< ignored. | |
383 | <li>374. operator>>ignored. | |
384 | <li>375. operator<<= ignored. | |
385 | <li>376. operator>>= ignored. | |
386 | <li>377. operator== ignored. | |
387 | <li>378. operator!= ignored. | |
388 | <li>379. operator<= ignored. | |
389 | <li>380. operator>= ignored. | |
390 | <li>381. operator&& ignored. | |
391 | <li>382. operator|| ignored. | |
392 | <li>383. operator++ ignored. | |
393 | <li>384. operator-- ignored. | |
394 | <li>385. operator, ignored. | |
395 | <li>386. operator-<* ignored. | |
396 | <li>387. operator-< ignored. | |
397 | <li>388. operator() ignored. | |
398 | <li>389. operator[] ignored. | |
399 | <li>390. operator+ ignored (unary). | |
400 | <li>391. operator- ignored (unary). | |
401 | <li>392. operator* ignored (unary). | |
402 | <li>393. operator& ignored (unary). | |
403 | <li>394. operator new[] ignored. | |
404 | <li>395. operator delete[] ignored. | |
405 | </ul> | |
406 | ||
407 | <H3><a name="Warnings_nn13"></a>14.8.4 Types and typemaps (400-499) </H3> | |
408 | ||
409 | ||
410 | <ul> | |
411 | <li>401. Nothing known about class 'name'. Ignored. | |
412 | <li>402. Base class 'name' is incomplete. | |
413 | <li>403. Class 'name' might be abstract. | |
414 | <li>450. Deprecated typemap feature ($source/$target). | |
415 | <li>451. Setting const char * variable may leak memory. | |
416 | <li>452. Reserved | |
417 | <li>453. Can't apply (pattern). No typemaps are defined. | |
418 | <li>460. Unable to use type <em>type</em> as a function argument. | |
419 | <li>461. Unable to use return type <em>type</em> in function <em>name</em>. | |
420 | <li>462. Unable to set variable of type <em>type</em>. | |
421 | <li>463. Unable to read variable of type <em>type</em>. | |
422 | <li>464. Unsupported constant value. | |
423 | <li>465. Unable to handle type <em>type</em>. | |
424 | <li>466. Unsupported variable type <em>type</em>. | |
425 | <li>467. Overloaded <em>declaration</em> not supported (no type checking rule for '<em>type</em>') | |
426 | <li>468. No 'throw' typemap defined for exception type <em>type</em> | |
427 | <li>469. No or improper directorin typemap defined for <em>type</em> | |
428 | <li>470. Thread/reentrant unsafe wrapping, consider returning by value instead. | |
429 | <li>471. Unable to use return type <em>type</em> in director method | |
430 | </ul> | |
431 | ||
432 | <H3><a name="Warnings_nn14"></a>14.8.5 Code generation (500-599)</H3> | |
433 | ||
434 | ||
435 | <ul> | |
436 | <li>501. Overloaded declaration ignored. <em>decl</em> | |
437 | <li>502. Overloaded constructor ignored. <em>decl</em> | |
438 | <li>503. Can't wrap '<em>identifier</em>' unless renamed to a valid identifier. | |
439 | <li>504. Function <em>name</em> must have a return type. | |
440 | <li>505. Variable length arguments discarded. | |
441 | <li>506. Can't wrap varargs with keyword arguments enabled. | |
442 | <li>507. Adding native function <em>name</em> not supported (ignored). | |
443 | <li>508. Declaration of '<em>name</em>' shadows declaration accessible via operator->() at <em>file:line</em>. | |
444 | <li>509. Overloaded <em>declaration</em> is shadowed by <em>declaration</em> at <em>file</em>:<em>line</em>. | |
445 | <li>510. Friend function '<em>name</em>' ignored. | |
446 | <li>511. Can't use keyword arguments with overloaded functions. | |
447 | <li>512. Overloaded <em>declaration</em> const ignored. Non-const method at <em>file</em>:<em>line</em> used. | |
448 | <li>513. Can't generate wrappers for unnamed struct/class. | |
449 | <li>514. | |
450 | <li>515. | |
451 | <li>516. Overloaded method <em>declaration</em> ignored. Method <em>declaration</em> at <em>file</em>:<em>line</em> used. | |
452 | </ul> | |
453 | ||
454 | <H3><a name="Warnings_nn15"></a>14.8.6 Language module specific (800-899) </H3> | |
455 | ||
456 | ||
457 | <ul> | |
458 | <li>801. Wrong name (corrected to '<em>name</em>'). (Ruby). | |
459 | </ul> | |
460 | ||
461 | <ul> | |
462 | <li>810. No jni typemap defined for <em>type</em> (Java). | |
463 | <li>811. No jtype typemap defined for <em>type</em> (Java). | |
464 | <li>812. No jstype typemap defined for <em>type</em> (Java). | |
465 | <li>813. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in Java. (Java). | |
466 | <li>814. | |
467 | <li>815. No javafinalize typemap defined for <em>type</em> (Java). | |
468 | <li>816. No javabody typemap defined for <em>type</em> (Java). | |
469 | <li>817. No javaout typemap defined for <em>type</em> (Java). | |
470 | <li>818. No javain typemap defined for <em>type</em> (Java). | |
471 | <li>819. No javadirectorin typemap defined for <em>type</em> (Java). | |
472 | <li>820. No javadirectorout typemap defined for <em>type</em> (Java). | |
473 | <li>821. | |
474 | <li>822. Covariant return types not supported in Java. Proxy method will return <em>basetype</em> (Java). | |
475 | <li>823. No javaconstruct typemap defined for <em>type</em> (Java). | |
476 | <li>824. Missing JNI descriptor in directorin typemap defined for <em>type</em> (Java). | |
477 | </ul> | |
478 | ||
479 | <ul> | |
480 | <li>830. No ctype typemap defined for <em>type</em> (C#). | |
481 | <li>831. No cstype typemap defined for <em>type</em> (C#). | |
482 | <li>832. No cswtype typemap defined for <em>type</em> (C#). | |
483 | <li>833. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in C#. (C#). | |
484 | <li>834. | |
485 | <li>835. No csfinalize typemap defined for <em>type</em> (C#). | |
486 | <li>836. No csbody typemap defined for <em>type</em> (C#). | |
487 | <li>837. No csout typemap defined for <em>type</em> (C#). | |
488 | <li>838. No csin typemap defined for <em>type</em> (C#). | |
489 | <li>839. | |
490 | <li>840. | |
491 | <li>841. | |
492 | <li>842. Covariant return types not supported in C#. Proxy method will return <em>basetype</em> (C#). | |
493 | <li>843. No csconstruct typemap defined for <em>type</em> (C#). | |
494 | <li>844. C# exception may not be thrown - no $excode or excode attribute in <em>typemap</em> typemap. (C#). | |
495 | <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#). | |
496 | </ul> | |
497 | ||
498 | <ul> | |
499 | <li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in Php4. (Php4). | |
500 | </ul> | |
501 | ||
502 | <H3><a name="Warnings_nn16"></a>14.8.7 User defined (900-999)</H3> | |
503 | ||
504 | ||
505 | <p> | |
506 | These numbers can be used by your own application. | |
507 | </p> | |
508 | ||
509 | <H2><a name="Warnings_nn17"></a>14.9 History</H2> | |
510 | ||
511 | ||
512 | <p> | |
513 | The ability to control warning messages was first added to SWIG-1.3.12. | |
514 | </p> | |
515 | ||
516 | </body> | |
517 | </html> |