Microchip Technology SW006023-2N Data Sheet

Page of 238
Compiler Command Line Driver
 2012 Microchip Technology Inc.
DS51686E-page 65
3.9.5
Options for Controlling Warnings and Errors
Warnings are diagnostic messages that report constructions that are not inherently 
erroneous, but that are risky or suggest there may have been an error. 
You can request many specific warnings with options beginning -W; for example, 
-Wimplicit,
 to request warnings on implicit declarations. Each of these specific 
warning options also has a negative form beginning -Wno- to turn off warnings; for 
example, -Wno-implicit. This manual lists only one of the two forms, whichever is 
not the default.
The following options control the amount and kinds of warnings produced by the 
compiler.
 
TABLE 3-8:
WARNING AND ERROR OPTIONS IMPLIED BY ALL WARNINGS
Option
Definition
-fsyntax-only
Check the code for syntax, but don’t do anything beyond that.
-pedantic
Issue all the warnings demanded by strict ANSI C. Reject all 
programs that use forbidden extensions.
-pedantic-errors
Like -pedantic, except that errors are produced rather than 
warnings.
-w
Inhibit all warning messages.
-Wall
This enables all the warnings about constructions that some 
users consider questionable, and that are easy to avoid (or 
modify to prevent the warning), even in conjunction with macros.
Note that some warning flags are not implied by -Wall. Some of 
them warn about constructions that users generally do not 
consider questionable, but which occasionally you might wish to 
check for; others warn about constructions that are necessary or 
hard to avoid in some cases, and there is no simple way to 
modify the code to suppress the warning. Some of them are 
enabled by -Wextra but many of them must be enabled 
individually. 
-Waddress
Warn about suspicious uses of memory addresses. These 
include using the address of a function in a conditional 
expression, such as void func(void); if (func), and 
comparisons against the memory address of a string literal, such 
as if (x == "abc"). Such uses typically indicate a programmer 
error: the address of a function always evaluates to true, so their 
use in a conditional usually indicates that the programmer forgot 
the parentheses in a function call; and comparisons against 
string literals result in unspecified behavior and are not portable 
in C, so they usually indicate that the programmer intended to 
use strcmp.
-Wchar-subscripts
Warn if an array subscript has type char.
-Wcomment
Warn whenever a comment-start sequence /* appears in a /* 
comment, or whenever a Backslash-Newline appears in a // 
comment.
-Wdiv-by-zero
Warn about compile-time integer division by zero. To inhibit the 
warning messages, use -Wno-div-by-zero. Floating-point 
division by zero is not warned about, as it can be a legitimate 
way of obtaining infinities and NaNs.
(This is the default.)
-Wformat
Check calls to printf and scanf, etc., to make sure that the 
arguments supplied have types appropriate to the format string 
specified.