⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 warning-options.html

📁 gcc手册
💻 HTML
📖 第 1 页 / 共 3 页
字号:
infinitely precise real numbers.  If you are doing this, then you need

to compute (by analyzing the code, or in some other way) the maximum or

likely maximum error that the computation introduces, and allow for it

when performing comparisons (and when producing output, but that's a

different problem).  In particular, instead of testing for equality, you

would check to see whether the two values have ranges that overlap; and

this is done with the relational operators, so equality comparisons are

probably mistaken.



     <br><dt><code>-Wtraditional </code>(C only)<code></code>

     <dd>Warn about certain constructs that behave differently in traditional and

ISO C.  Also warn about ISO C constructs that have no traditional C

equivalent, and/or problematic constructs which should be avoided.



          <ul>

<li>Macro parameters that appear within string literals in the macro body. 

In traditional C macro replacement takes place within string literals,

but does not in ISO C.



          <li>In traditional C, some preprocessor directives did not exist. 

Traditional preprocessors would only consider a line to be a directive

if the <code>#</code> appeared in column 1 on the line.  Therefore

<code>-Wtraditional</code> warns about directives that traditional C

understands but would ignore because the <code>#</code> does not appear as the

first character on the line.  It also suggests you hide directives like

<code>#pragma</code> not understood by traditional C by indenting them.  Some

traditional implementations would not recognize <code>#elif</code>, so it

suggests avoiding it altogether.



          <li>A function-like macro that appears without arguments.



          <li>The unary plus operator.



          <li>The <code>U</code> integer constant suffix, or the <code>F</code> or <code>L</code> floating point

constant suffixes.  (Traditional C does support the <code>L</code> suffix on integer

constants.)  Note, these suffixes appear in macros defined in the system

headers of most modern systems, e.g. the <code>_MIN</code>/<code>_MAX</code> macros in <code>&lt;limits.h&gt;</code>. 

Use of these macros in user code might normally lead to spurious

warnings, however gcc's integrated preprocessor has enough context to

avoid warning in these cases.



          <li>A function declared external in one block and then used after the end of

the block.



          <li>A <code>switch</code> statement has an operand of type <code>long</code>.



          <li>A non-<code>static</code> function declaration follows a <code>static</code> one. 

This construct is not accepted by some traditional C compilers.



          <li>The ISO type of an integer constant has a different width or

signedness from its traditional type.  This warning is only issued if

the base of the constant is ten.  I.e. hexadecimal or octal values, which

typically represent bit patterns, are not warned about.



          <li>Usage of ISO string concatenation is detected.



          <li>Initialization of automatic aggregates.



          <li>Identifier conflicts with labels.  Traditional C lacks a separate

namespace for labels.



          <li>Initialization of unions.  If the initializer is zero, the warning is

omitted.  This is done under the assumption that the zero initializer in

user code appears conditioned on e.g. <code>__STDC__</code> to avoid missing

initializer warnings and relies on default initialization to zero in the

traditional C case.



          <li>Conversions by prototypes between fixed/floating point values and vice

versa.  The absence of these prototypes when compiling with traditional

C would cause serious problems.  This is a subset of the possible

conversion warnings, for the full set use <code>-Wconversion</code>.



          <li>Use of ISO C style function definitions.  This warning intentionally is

<em>not</em> issued for prototype declarations or variadic functions

because these ISO C features will appear in your code when using

libiberty's traditional C compatibility macros, <code>PARAMS</code> and

<code>VPARAMS</code>.  This warning is also bypassed for nested functions

because that feature is already a gcc extension and thus not relevant to

traditional C compatibility. 

</ul>



     <br><dt><code>-Wundef</code>

     <dd>Warn if an undefined identifier is evaluated in an <code>#if</code> directive.



     <br><dt><code>-Wendif-labels</code>

     <dd>Warn whenever an <code>#else</code> or an <code>#endif</code> are followed by text.



     <br><dt><code>-Wshadow</code>

     <dd>Warn whenever a local variable shadows another local variable, parameter or

global variable or whenever a built-in function is shadowed.



     <br><dt><code>-Wlarger-than-</code><var>len</var><code></code>

     <dd>Warn whenever an object of larger than <var>len</var> bytes is defined.



     <br><dt><code>-Wpointer-arith</code>

     <dd>Warn about anything that depends on the "size of" a function type or

of <code>void</code>.  GNU C assigns these types a size of 1, for

convenience in calculations with <code>void *</code> pointers and pointers

to functions.



     <br><dt><code>-Wbad-function-cast </code>(C only)<code></code>

     <dd>Warn whenever a function call is cast to a non-matching type. 

For example, warn if <code>int malloc()</code> is cast to <code>anything *</code>.



     <br><dt><code>-Wcast-qual</code>

     <dd>Warn whenever a pointer is cast so as to remove a type qualifier from

the target type.  For example, warn if a <code>const char *</code> is cast

to an ordinary <code>char *</code>.



     <br><dt><code>-Wcast-align</code>

     <dd>Warn whenever a pointer is cast such that the required alignment of the

target is increased.  For example, warn if a <code>char *</code> is cast to

an <code>int *</code> on machines where integers can only be accessed at

two- or four-byte boundaries.



     <br><dt><code>-Wwrite-strings</code>

     <dd>When compiling C, give string constants the type <code>const

char[</code><var>length</var><code>]</code> so that

copying the address of one into a non-<code>const</code> <code>char *</code>

pointer will get a warning; when compiling C++, warn about the

deprecated conversion from string constants to <code>char *</code>. 

These warnings will help you find at

compile time code that can try to write into a string constant, but

only if you have been very careful about using <code>const</code> in

declarations and prototypes.  Otherwise, it will just be a nuisance;

this is why we did not make <code>-Wall</code> request these warnings.



     <br><dt><code>-Wconversion</code>

     <dd>Warn if a prototype causes a type conversion that is different from what

would happen to the same argument in the absence of a prototype.  This

includes conversions of fixed point to floating and vice versa, and

conversions changing the width or signedness of a fixed point argument

except when the same as the default promotion.



     <p>Also, warn if a negative integer constant expression is implicitly

converted to an unsigned type.  For example, warn about the assignment

<code>x = -1</code> if <code>x</code> is unsigned.  But do not warn about explicit

casts like <code>(unsigned) -1</code>.



     <br><dt><code>-Wsign-compare</code>

     <dd>Warn when a comparison between signed and unsigned values could produce

an incorrect result when the signed value is converted to unsigned. 

This warning is enabled by <code>-W</code>, and by <code>-Wall</code>

in C++ only.



     <br><dt><code>-Waggregate-return</code>

     <dd>Warn if any functions that return structures or unions are defined or

called.  (In languages where you can return an array, this also elicits

a warning.)



     <br><dt><code>-Wstrict-prototypes </code>(C only)<code></code>

     <dd>Warn if a function is declared or defined without specifying the

argument types.  (An old-style function definition is permitted without

a warning if preceded by a declaration which specifies the argument

types.)



     <br><dt><code>-Wmissing-prototypes </code>(C only)<code></code>

     <dd>Warn if a global function is defined without a previous prototype

declaration.  This warning is issued even if the definition itself

provides a prototype.  The aim is to detect global functions that fail

to be declared in header files.



     <br><dt><code>-Wmissing-declarations</code>

     <dd>Warn if a global function is defined without a previous declaration. 

Do so even if the definition itself provides a prototype. 

Use this option to detect global functions that are not declared in

header files.



     <br><dt><code>-Wmissing-noreturn</code>

     <dd>Warn about functions which might be candidates for attribute <code>noreturn</code>. 

Note these are only possible candidates, not absolute ones.  Care should

be taken to manually verify functions actually do not ever return before

adding the <code>noreturn</code> attribute, otherwise subtle code generation

bugs could be introduced.  You will not get a warning for <code>main</code> in

hosted C environments.



     <br><dt><code>-Wmissing-format-attribute</code>

     <dd>If <code>-Wformat</code> is enabled, also warn about functions which might be

candidates for <code>format</code> attributes.  Note these are only possible

candidates, not absolute ones.  GCC will guess that <code>format</code>

attributes might be appropriate for any function that calls a function

like <code>vprintf</code> or <code>vscanf</code>, but this might not always be the

case, and some functions for which <code>format</code> attributes are

appropriate may not be detected.  This option has no effect unless

<code>-Wformat</code> is enabled (possibly by <code>-Wall</code>).



     <br><dt><code>-Wno-multichar</code>

     <dd>Do not warn if a multicharacter constant (<code>'FOOF'</code>) is used. 

Usually they indicate a typo in the user's code, as they have

implementation-defined values, and should not be used in portable code.



     <br><dt><code>-Wno-deprecated-declarations</code>

     <dd>Do not warn about uses of functions, variables, and types marked as

deprecated by using the <code>deprecated</code> attribute. 

(see <a href="Function-Attributes.html#Function%20Attributes">Function Attributes</a>, see <a href="Variable-Attributes.html#Variable%20Attributes">Variable Attributes</a>,

see <a href="Type-Attributes.html#Type%20Attributes">Type Attributes</a>.)



     <br><dt><code>-Wpacked</code>

     <dd>Warn if a structure is given the packed attribute, but the packed

attribute has no effect on the layout or size of the structure. 

Such structures may be mis-aligned for little benefit.  For

instance, in this code, the variable <code>f.x</code> in <code>struct bar</code>

will be misaligned even though <code>struct bar</code> does not itself

have the packed attribute:



     <pre class="smallexample">          struct foo {

            int x;

            char a, b, c, d;

          } __attribute__((packed));

          struct bar {

            char z;

            struct foo f;

          };

          </pre>



     <br><dt><code>-Wpadded</code>

     <dd>Warn if padding is included in a structure, either to align an element

of the structure or to align the whole structure.  Sometimes when this

happens it is possible to rearrange the fields of the structure to

reduce the padding and so make the structure smaller.



     <br><dt><code>-Wredundant-decls</code>

     <dd>Warn if anything is declared more than once in the same scope, even in

cases where multiple declaration is valid and changes nothing.



     <br><dt><code>-Wnested-externs </code>(C only)<code></code>

     <dd>Warn if an <code>extern</code> declaration is encountered within a function.



     <br><dt><code>-Wunreachable-code</code>

     <dd>Warn if the compiler detects that code will never be executed.



     <p>This option is intended to warn when the compiler detects that at

least a whole line of source code will never be executed, because

some condition is never satisfied or because it is after a

procedure that never returns.



     <p>It is possible for this option to produce a warning even though there

are circumstances under which part of the affected line can be executed,

so care should be taken when removing apparently-unreachable code.



     <p>For instance, when a function is inlined, a warning may mean that the

line is unreachable in only one inlined copy of the function.



     <p>This option is not made part of <code>-Wall</code> because in a debugging

version of a program there is often substantial code which checks

correct functioning of the program and is, hopefully, unreachable

because the program does work.  Another common use of unreachable

code is to provide behavior which is selectable at compile-time.



     <br><dt><code>-Winline</code>

     <dd>Warn if a function can not be inlined and it was declared as inline.



     <br><dt><code>-Wlong-long</code>

     <dd>Warn if <code>long long</code> type is used.  This is default.  To inhibit

the warning messages, use <code>-Wno-long-long</code>.  Flags

<code>-Wlong-long</code> and <code>-Wno-long-long</code> are taken into account

only when <code>-pedantic</code> flag is used.



     <br><dt><code>-Wdisabled-optimization</code>

     <dd>Warn if a requested optimization pass is disabled.  This warning does

not generally indicate that there is anything wrong with your code; it

merely indicates that GCC's optimizers were unable to handle the code

effectively.  Often, the problem is that your code is too big or too

complex; GCC will refuse to optimize programs when the optimization

itself is likely to take inordinate amounts of time.



     <br><dt><code>-Werror</code>

     <dd>Make all warnings into errors. 

</dl>



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -