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

📄 non-bugs.html

📁 自己收集的linux入门到学懂高级编程书集 包括linux程序设计第三版
💻 HTML
字号:
<html lang="en"><head><title>Using the GNU Compiler Collection (GCC)</title><meta http-equiv="Content-Type" content="text/html"><meta name="description" content="Using the GNU Compiler Collection (GCC)"><meta name="generator" content="makeinfo 4.6"><!--Copyright &copy; 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.   <p>Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being "GNU General Public License" and "FundingFree Software", the Front-Cover texts being (a) (see below), and withthe Back-Cover Texts being (b) (see below).  A copy of the license isincluded in the section entitled "GNU Free Documentation License".   <p>(a) The FSF's Front-Cover Text is:   <p>A GNU Manual   <p>(b) The FSF's Back-Cover Text is:   <p>You have freedom to copy and modify this GNU Manual, like GNU     software.  Copies published by the Free Software Foundation raise     funds for GNU development.--><meta http-equiv="Content-Style-Type" content="text/css"><style type="text/css"><!--  pre.display { font-family:inherit }  pre.format  { font-family:inherit }  pre.smalldisplay { font-family:inherit; font-size:smaller }  pre.smallformat  { font-family:inherit; font-size:smaller }  pre.smallexample { font-size:smaller }  pre.smalllisp    { font-size:smaller }--></style></head><body><div class="node"><p>Node:&nbsp;<a name="Non-bugs">Non-bugs</a>,Next:&nbsp;<a rel="next" accesskey="n" href="Warnings-and-Errors.html#Warnings%20and%20Errors">Warnings and Errors</a>,Previous:&nbsp;<a rel="previous" accesskey="p" href="Protoize-Caveats.html#Protoize%20Caveats">Protoize Caveats</a>,Up:&nbsp;<a rel="up" accesskey="u" href="Trouble.html#Trouble">Trouble</a><hr><br></div><h3 class="section">Certain Changes We Don't Want to Make</h3><p>This section lists changes that people frequently request, but whichwe do not make because we think GCC is better without them.     <ul><li>Checking the number and type of arguments to a function which has anold-fashioned definition and no prototype.     <p>Such a feature would work only occasionally--only for calls that appearin the same file as the called function, following the definition.  Theonly way to check all calls reliably is to add a prototype for thefunction.  But adding a prototype eliminates the motivation for thisfeature.  So the feature is not worthwhile.     </p><li>Warning about using an expression whose type is signed as a shift count.     <p>Shift count operands are probably signed more often than unsigned. Warning about this would cause far more annoyance than good.     </p><li>Warning about assigning a signed value to an unsigned variable.     <p>Such assignments must be very common; warning about them would causemore annoyance than good.     </p><li>Warning when a non-void function value is ignored.     <p>Coming as I do from a Lisp background, I balk at the idea that there issomething dangerous about discarding a value.  There are functions thatreturn values which some callers may find useful; it makes no sense toclutter the program with a cast to <code>void</code> whenever the value isn'tuseful.     </p><li>Making <code>-fshort-enums</code> the default.     <p>This would cause storage layout to be incompatible with most other Ccompilers.  And it doesn't seem very important, given that you can getthe same result in other ways.  The case where it matters most is whenthe enumeration-valued object is inside a structure, and in that caseyou can specify a field width explicitly.     </p><li>Making bit-fields unsigned by default on particular machines where "theABI standard" says to do so.     <p>The ISO C standard leaves it up to the implementation whether a bit-fielddeclared plain <code>int</code> is signed or not.  This in effect creates twoalternative dialects of C.     <p>The GNU C compiler supports both dialects; you can specify the signeddialect with <code>-fsigned-bitfields</code> and the unsigned dialect with<code>-funsigned-bitfields</code>.  However, this leaves open the question ofwhich dialect to use by default.     <p>Currently, the preferred dialect makes plain bit-fields signed, becausethis is simplest.  Since <code>int</code> is the same as <code>signed int</code> inevery other context, it is cleanest for them to be the same in bit-fieldsas well.     <p>Some computer manufacturers have published Application Binary Interfacestandards which specify that plain bit-fields should be unsigned.  It isa mistake, however, to say anything about this issue in an ABI.  This isbecause the handling of plain bit-fields distinguishes two dialects of C. Both dialects are meaningful on every type of machine.  Whether aparticular object file was compiled using signed bit-fields or unsignedis of no concern to other object files, even if they access the samebit-fields in the same data structures.     <p>A given program is written in one or the other of these two dialects. The program stands a chance to work on most any machine if it iscompiled with the proper dialect.  It is unlikely to work at all ifcompiled with the wrong dialect.     <p>Many users appreciate the GNU C compiler because it provides anenvironment that is uniform across machines.  These users would beinconvenienced if the compiler treated plain bit-fields differently oncertain machines.     <p>Occasionally users write programs intended only for a particular machinetype.  On these occasions, the users would benefit if the GNU C compilerwere to support by default the same dialect as the other compilers onthat machine.  But such applications are rare.  And users writing aprogram to run on more than one type of machine cannot possibly benefitfrom this kind of compatibility.     <p>This is why GCC does and will treat plain bit-fields in the samefashion on all types of machines (by default).     <p>There are some arguments for making bit-fields unsigned by default on allmachines.  If, for example, this becomes a universal de facto standard,it would make sense for GCC to go along with it.  This is somethingto be considered in the future.     <p>(Of course, users strongly concerned about portability should indicateexplicitly in each bit-field whether it is signed or not.  In this way,they write programs which have the same meaning in both C dialects.)     </p><li>Undefining <code>__STDC__</code> when <code>-ansi</code> is not used.     <p>Currently, GCC defines <code>__STDC__</code> unconditionally.  This providesgood results in practice.     <p>Programmers normally use conditionals on <code>__STDC__</code> to ask whetherit is safe to use certain features of ISO C, such as functionprototypes or ISO token concatenation.  Since plain <code>gcc</code> supportsall the features of ISO C, the correct answer to these questions is"yes".     <p>Some users try to use <code>__STDC__</code> to check for the availability ofcertain library facilities.  This is actually incorrect usage in an ISOC program, because the ISO C standard says that a conformingfreestanding implementation should define <code>__STDC__</code> even though itdoes not have the library facilities.  <code>gcc -ansi -pedantic</code> is aconforming freestanding implementation, and it is therefore required todefine <code>__STDC__</code>, even though it does not come with an ISO Clibrary.     <p>Sometimes people say that defining <code>__STDC__</code> in a compiler thatdoes not completely conform to the ISO C standard somehow violates thestandard.  This is illogical.  The standard is a standard for compilersthat claim to support ISO C, such as <code>gcc -ansi</code>--not for othercompilers such as plain <code>gcc</code>.  Whatever the ISO C standard saysis relevant to the design of plain <code>gcc</code> without <code>-ansi</code> onlyfor pragmatic reasons, not as a requirement.     <p>GCC normally defines <code>__STDC__</code> to be 1, and in additiondefines <code>__STRICT_ANSI__</code> if you specify the <code>-ansi</code> option,or a <code>-std</code> option for strict conformance to some version of ISO C. On some hosts, system include files use a different convention, where<code>__STDC__</code> is normally 0, but is 1 if the user specifies strictconformance to the C Standard.  GCC follows the host convention whenprocessing system include files, but when processing user files it followsthe usual GNU C convention.     </p><li>Undefining <code>__STDC__</code> in C++.     <p>Programs written to compile with C++-to-C translators get thevalue of <code>__STDC__</code> that goes with the C compiler that issubsequently used.  These programs must test <code>__STDC__</code>to determine what kind of C preprocessor that compiler uses:whether they should concatenate tokens in the ISO C fashionor in the traditional fashion.     <p>These programs work properly with GNU C++ if <code>__STDC__</code> is defined. They would not work otherwise.     <p>In addition, many header files are written to provide prototypes in ISOC but not in traditional C.  Many of these header files can work withoutchange in C++ provided <code>__STDC__</code> is defined.  If <code>__STDC__</code>is not defined, they will all fail, and will all need to be changed totest explicitly for C++ as well.     </p><li>Deleting "empty" loops.     <p>Historically, GCC has not deleted "empty" loops under theassumption that the most likely reason you would put one in a program isto have a delay, so deleting them will not make real programs run anyfaster.     <p>However, the rationale here is that optimization of a nonempty loopcannot produce an empty one, which holds for C but is not always thecase for C++.     <p>Moreover, with <code>-funroll-loops</code> small "empty" loops are alreadyremoved, so the current behavior is both sub-optimal and inconsistentand will change in the future.     </p><li>Making side effects happen in the same order as in some other compiler.     <p>It is never safe to depend on the order of evaluation of side effects. For example, a function call like this may very well behave differentlyfrom one compiler to another:     <pre class="smallexample">          void func (int, int);                    int i = 2;          func (i++, i++);          </pre>     <p>There is no guarantee (in either the C or the C++ standard languagedefinitions) that the increments will be evaluated in any particularorder.  Either increment might happen first.  <code>func</code> might get thearguments <code>2, 3</code>, or it might get <code>3, 2</code>, or even <code>2, 2</code>.     </p><li>Making certain warnings into errors by default.     <p>Some ISO C testsuites report failure when the compiler does not producean error message for a certain program.     <p>ISO C requires a "diagnostic" message for certain kinds of invalidprograms, but a warning is defined by GCC to count as a diagnostic.  IfGCC produces a warning but not an error, that is correct ISO C support. If test suites call this "failure", they should be run with the GCCoption <code>-pedantic-errors</code>, which will turn these warnings intoerrors.   </ul>   </body></html>

⌨️ 快捷键说明

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