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

📄 warning-options.html

📁 自己收集的linux入门到学懂高级编程书集 包括linux程序设计第三版
💻 HTML
📖 第 1 页 / 共 3 页
字号:
     <br><dt><code>-Wtraditional </code>(C only)<code></code>     <dd>Warn about certain constructs that behave differently in traditional andISO C.  Also warn about ISO C constructs that have no traditional Cequivalent, 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 directiveif the <code>#</code> appeared in column 1 on the line.  Therefore<code>-Wtraditional</code> warns about directives that traditional Cunderstands but would ignore because the <code>#</code> does not appear as thefirst character on the line.  It also suggests you hide directives like<code>#pragma</code> not understood by traditional C by indenting them.  Sometraditional implementations would not recognize <code>#elif</code>, so itsuggests 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 pointconstant suffixes.  (Traditional C does support the <code>L</code> suffix on integerconstants.)  Note, these suffixes appear in macros defined in the systemheaders 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 spuriouswarnings, however GCC's integrated preprocessor has enough context toavoid warning in these cases.          <li>A function declared external in one block and then used after the end ofthe 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 orsignedness from its traditional type.  This warning is only issued ifthe base of the constant is ten.  I.e. hexadecimal or octal values, whichtypically 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 separatenamespace for labels.          <li>Initialization of unions.  If the initializer is zero, the warning isomitted.  This is done under the assumption that the zero initializer inuser code appears conditioned on e.g. <code>__STDC__</code> to avoid missinginitializer warnings and relies on default initialization to zero in thetraditional C case.          <li>Conversions by prototypes between fixed/floating point values and viceversa.  The absence of these prototypes when compiling with traditionalC would cause serious problems.  This is a subset of the possibleconversion 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 functionsbecause these ISO C features will appear in your code when usinglibiberty's traditional C compatibility macros, <code>PARAMS</code> and<code>VPARAMS</code>.  This warning is also bypassed for nested functionsbecause that feature is already a GCC extension and thus not relevant totraditional C compatibility. </ul>     <br><dt><code>-Wdeclaration-after-statement </code>(C only)<code></code>     <dd>Warn when a declaration is found after a statement in a block.  Thisconstruct, known from C++, was introduced with ISO C99 and is by defaultallowed in GCC.  It is not supported by ISO C90 and was not supported byGCC versions before GCC 3.0.  See <a href="Mixed-Declarations.html#Mixed%20Declarations">Mixed Declarations</a>.     <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 orglobal 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 orof <code>void</code>.  GNU C assigns these types a size of 1, forconvenience in calculations with <code>void *</code> pointers and pointersto 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 fromthe target type.  For example, warn if a <code>const char *</code> is castto an ordinary <code>char *</code>.     <br><dt><code>-Wcast-align</code>     <dd>Warn whenever a pointer is cast such that the required alignment of thetarget is increased.  For example, warn if a <code>char *</code> is cast toan <code>int *</code> on machines where integers can only be accessed attwo- or four-byte boundaries.     <br><dt><code>-Wwrite-strings</code>     <dd>When compiling C, give string constants the type <code>constchar[</code><var>length</var><code>]</code> so thatcopying the address of one into a non-<code>const</code> <code>char *</code>pointer will get a warning; when compiling C++, warn about thedeprecated conversion from string constants to <code>char *</code>. These warnings will help you find atcompile time code that can try to write into a string constant, butonly if you have been very careful about using <code>const</code> indeclarations 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 whatwould happen to the same argument in the absence of a prototype.  Thisincludes conversions of fixed point to floating and vice versa, andconversions changing the width or signedness of a fixed point argumentexcept when the same as the default promotion.     <p>Also, warn if a negative integer constant expression is implicitlyconverted 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 explicitcasts like <code>(unsigned) -1</code>.     <br><dt><code>-Wsign-compare</code>     <dd>Warn when a comparison between signed and unsigned values could producean incorrect result when the signed value is converted to unsigned. This warning is also enabled by <code>-Wextra</code>; to get the other warningsof <code>-Wextra</code> without this warning, use <code>-Wextra -Wno-sign-compare</code>.     <br><dt><code>-Waggregate-return</code>     <dd>Warn if any functions that return structures or unions are defined orcalled.  (In languages where you can return an array, this also elicitsa warning.)     <br><dt><code>-Wstrict-prototypes </code>(C only)<code></code>     <dd>Warn if a function is declared or defined without specifying theargument types.  (An old-style function definition is permitted withouta warning if preceded by a declaration which specifies the argumenttypes.)     <br><dt><code>-Wold-style-definition </code>(C only)<code></code>     <dd>Warn if an old-style function definition is used.  A warning is giveneven if there is a previous prototype.     <br><dt><code>-Wmissing-prototypes </code>(C only)<code></code>     <dd>Warn if a global function is defined without a previous prototypedeclaration.  This warning is issued even if the definition itselfprovides a prototype.  The aim is to detect global functions that failto be declared in header files.     <br><dt><code>-Wmissing-declarations </code>(C only)<code></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 inheader 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 shouldbe taken to manually verify functions actually do not ever return beforeadding the <code>noreturn</code> attribute, otherwise subtle code generationbugs could be introduced.  You will not get a warning for <code>main</code> inhosted C environments.     <br><dt><code>-Wmissing-format-attribute</code>     <dd>If <code>-Wformat</code> is enabled, also warn about functions which might becandidates for <code>format</code> attributes.  Note these are only possiblecandidates, not absolute ones.  GCC will guess that <code>format</code>attributes might be appropriate for any function that calls a functionlike <code>vprintf</code> or <code>vscanf</code>, but this might not always be thecase, and some functions for which <code>format</code> attributes areappropriate 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 haveimplementation-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 asdeprecated 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 packedattribute has no effect on the layout or size of the structure. Such structures may be mis-aligned for little benefit.  Forinstance, 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 itselfhave 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 elementof the structure or to align the whole structure.  Sometimes when thishappens it is possible to rearrange the fields of the structure toreduce 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 incases 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 atleast a whole line of source code will never be executed, becausesome condition is never satisfied or because it is after aprocedure that never returns.     <p>It is possible for this option to produce a warning even though thereare 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 theline is unreachable in only one inlined copy of the function.     <p>This option is not made part of <code>-Wall</code> because in a debuggingversion of a program there is often substantial code which checkscorrect functioning of the program and is, hopefully, unreachablebecause the program does work.  Another common use of unreachablecode 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. Even with this option, the compiler will not warn about failures toinline functions declared in system headers.     <p>The compiler uses a variety of heuristics to determine whether or notto inline a function.  For example, the compiler takes into accountthe size of the function being inlined and the the amount of inliningthat has already been done in the current function.  Therefore,seemingly insignificant changes in the source program can cause thewarnings produced by <code>-Winline</code> to appear or disappear.     <br><dt><code>-Wno-invalid-offsetof </code>(C++ only)<code></code>     <dd>Suppress warnings from applying the <code>offsetof</code> macro to a non-PODtype.  According to the 1998 ISO C++ standard, applying <code>offsetof</code>to a non-POD type is undefined.  In existing C++ implementations,however, <code>offsetof</code> typically gives meaningful results even whenapplied to certain kinds of non-POD types. (Such as a simple<code>struct</code> that fails to be a POD type only by virtue of having aconstructor.)  This flag is for users who are aware that they arewriting nonportable code and who have deliberately chosen to ignore thewarning about it.     <p>The restrictions on <code>offsetof</code> may be relaxed in a future versionof the C++ standard.     <br><dt><code>-Winvalid-pch</code>     <dd>Warn if a precompiled header (see <a href="Precompiled-Headers.html#Precompiled%20Headers">Precompiled Headers</a>) is found inthe search path but can't be used.     <br><dt><code>-Wlong-long</code>     <dd>Warn if <code>long long</code> type is used.  This is default.  To inhibitthe warning messages, use <code>-Wno-long-long</code>.  Flags<code>-Wlong-long</code> and <code>-Wno-long-long</code> are taken into accountonly when <code>-pedantic</code> flag is used.     <br><dt><code>-Wvariadic-macros</code>     <dd>Warn if variadic macros are used in pedantic ISO C90 mode, or the GNUalternate syntax when in pedantic ISO C99 mode.  This is default. To inhibit the warning messages, use <code>-Wno-variadic-macros</code>.     <br><dt><code>-Wdisabled-optimization</code>     <dd>Warn if a requested optimization pass is disabled.  This warning doesnot generally indicate that there is anything wrong with your code; itmerely indicates that GCC's optimizers were unable to handle the codeeffectively.  Often, the problem is that your code is too big or toocomplex; GCC will refuse to optimize programs when the optimizationitself 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 + -