summaryrefslogtreecommitdiff
path: root/Doc/Manual/Warnings.html
blob: 96e35902afd9a18ecd9c94a259e1f22e16722f13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
<!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 (800-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") blah * {
   ...
}
</pre>
</div>

<p>
In this case, the warning message will be printed whenever the typemap is actually used.
</p>

<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 'filename'.
<li>202. Could not evaluate 'expr'.
</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&amp; ignored.
<li>359. operator| ignored.
<li>360. operator~ ignored.
<li>361. operator! ignored.
<li>362. operator= ignored.
<li>363. operator&lt; ignored.
<li>364. operator&gt; 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&amp;= ignored.
<li>372. operator|= ignored.
<li>373. operator&lt;&lt; ignored.
<li>374. operator&gt;&gt;ignored.
<li>375. operator&lt;&lt;= ignored.
<li>376. operator&gt;&gt;= ignored.
<li>377. operator== ignored.
<li>378. operator!= ignored.
<li>379. operator&lt;= ignored.
<li>380. operator&gt;= ignored.
<li>381. operator&amp;&amp; ignored.
<li>382. operator|| ignored.
<li>383. operator++ ignored.
<li>384. operator-- ignored.
<li>385. operator, ignored.
<li>386. operator-&lt;* ignored.
<li>387. operator-&lt; 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&amp; 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.
<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-&gt;(), 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>
</ul>

<H3><a name="Warnings_nn15"></a>14.9.6 Language module specific (800-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>