📄 index.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN"><!-- This collection of hypertext pages is Copyright 1995-2005 by Steve Summit. --><!-- Content from the book "C Programming FAQs: Frequently Asked Questions" --><!-- (Addison-Wesley, 1995, ISBN 0-201-84519-9) is made available here by --><!-- permission of the author and the publisher as a service to the community. --><!-- It is intended to complement the use of the published text --><!-- and is protected by international copyright laws. --><!-- The on-line content may be accessed freely for personal use --><!-- but may not be published or retransmitted without explicit permission. --><!-- --><!-- this page built Sat Dec 24 21:47:46 2005 by faqproc version 2.7 --><!-- from source file cpp.sgml dated Wed Dec 21 13:52:14 2005 --><!-- corresponding to FAQ list version 4.0 --><html><!-- Mirrored from c-faq.com/cpp/index.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 07:55:10 GMT --><head><meta name=GENERATOR content="faqproc"><title>C Preprocessor</title></head><body bgcolor="#ffffff"> <a href="../index-2.html"><img src="../images/buttontop.gif" alt="top/contents"></a><a href="../search.html"><img src="../images/buttonsrch.gif" alt="search"></a><hr><H1>10. C Preprocessor</H1><p><a href="safemacros.html" rel=subdocument>10.1</a>I'm trying to definea few simple little function-like macrossuch as<pre> #define square(x) x * x</pre>but they're not always working.</p><p><a href="slm.html" rel=subdocument>10.2</a>Here aresome cute preprocessor macros:<pre> #define begin { #define end }</pre>With these,I can write C code that looks more like Pascal.What do y'all think?</p><p><a href="swapmacro.html" rel=subdocument>10.3</a>How can I write a generic macro to swap two values?</p><p><a href="multistmt.html" rel=subdocument>10.4</a>What's the best way to write a multi-statement macro?</p><p><a href="typedefvsdefine.html" rel=subdocument>10.5</a>What's the difference between using a <TT>typedef</TT>ora <TT>#define</TT>for a user-defined type?</p><p><a href="constvsdefine.html" rel=subdocument>10.5b</a>What's the difference between<pre> const MAXSIZE = 100;</pre><pre>and</pre><pre> #define MAXSIZE 100</pre></p><p><a href="hfiles.html" rel=subdocument>10.6</a>I'm splitting up a programinto multiple source filesfor the first time,and I'm wondering what to put in <TT>.c</TT> filesand what to put in <TT>.h</TT> files.(What does ``<TT>.h</TT>''mean,anyway?)</p><p><a href="nestincl.html" rel=subdocument>10.7</a>Is it acceptable for one header file to <TT>#include</TT> another?</p><p><a href="inclkinds.html" rel=subdocument>10.8a</a>What's the difference between<TT>#include <></TT>and<TT>#include ""</TT>?</p><p><a href="cppsearchpath.html" rel=subdocument>10.8b</a>What are the complete rules for header file searching?</p><p><a href="headerglom.html" rel=subdocument>10.9</a>I'm getting strangesyntax errorson the very firstdeclaration ina file,but it looks fine.</p><p><a href="def3rdparty.html" rel=subdocument>10.10</a>I'm using header fileswhichaccompany two different third-party libraries,and they are ``helpfully'' definingcommon macros such as <TT>TRUE</TT>,<TT>FALSE</TT>,<TT>Min()</TT>,and <TT>Max()</TT>,but the definitions clash with each otherand with definitions I'dalready established in my own header files.What can I do?</p><p><a href="extlibs.html" rel=subdocument>10.10b</a>I'm #including therightheader file forthe library function I'm using,but the linker keeps saying it's undefined.</p><p><a href="missinghdr.html" rel=subdocument>10.11</a>I'm compiling a program, andI seem to be missingoneof theheader files itrequires.Can someone send mea copy?</p><p><a href="ifstrcmp.html" rel=subdocument>10.12</a>How can I construct preprocessor <TT>#if</TT> expressionswhich compare strings?</p><p><a href="ifexpr.html" rel=subdocument>10.13</a>Does the <TT>sizeof</TT> operator work in preprocessor <TT>#if</TT> directives?</p><p><a href="ifddef.html" rel=subdocument>10.14</a>Can I use an <TT>#ifdef</TT> in a <TT>#define</TT> line,to define something two differentways,like this?<pre> #define a b \ #ifdef whatever c d #else e f g #endif</pre></p><p><a href="iftypedef.html" rel=subdocument>10.15</a>Is there anything likean <TT>#ifdef</TT> for <TT>typedef</TT>s?</p><p><a href="ifendian.html" rel=subdocument>10.16</a>How can I use a preprocessor <TT>#if</TT> expression totellwhether a machine's byte orderis big-endian or little-endian?</p><p><a href="ifdefsyntax.html" rel=subdocument>10.17</a>I'm getting strange syntax errors insidelinesI've<TT>#ifdef</TT>fed out.</p><p><a href="unifdef.html" rel=subdocument>10.18</a>I inherited some codewhich contains far too many <TT>#ifdef</TT>'s for my taste.How can I preprocessthecodetoleave only one conditional compilation set,without running it through the preprocessorand expanding all of the <TT>#include</TT>'s and <TT>#define</TT>'s as well?</p><p><a href="listpredef.html" rel=subdocument>10.19</a>How can I list all of the predefined identifiers?</p><p><a href="oldpaste.html" rel=subdocument>10.20</a>I have some old code that tries to construct identifiers with amacro like<pre>#define Paste(a, b) a/**/b</pre>but it doesn't work any more.</p><p><a href="charize.html" rel=subdocument>10.21</a>I have an old macro<pre>#define CTRL(c) ('c' & 037)</pre>that doesn'tseem towork any more.</p><p><a href="macstrexp2.html" rel=subdocument>10.22</a>Why is the macro<pre> #define TRACE(n) printf("TRACE: %d\n", n)</pre>giving me the warning ``macro replacement within a string literal''?It seems to be expanding<pre> TRACE(count);</pre>as<pre> printf("TRACE: %d\count", count);</pre></p><p><a href="macstrexp1.html" rel=subdocument>10.23</a>How can Iusea macro argumentinsidea stringliteralin the macro expansion?</p><p><a href="stringize.html" rel=subdocument>10.24</a>I'm trying to usethe ANSI ``stringizing'' preprocessing operator`<TT>#</TT>'to insert the value of a symbolic constant into a message,but it keepsstringizing the macro's name rather than itsvalue.</p><p><a href="notgeneral.html" rel=subdocument>10.25</a>I've got this tricky preprocessing I want to doandI can't figure out a wayto do it.</p><p><a href="varargs.html" rel=subdocument>10.26</a>How can I write a macro which takes a variable number ofarguments,or use the preprocessor to ``turn off'' a function call with avariable number of arguments?</p><p><a href="debugmacs.html" rel=subdocument>10.27</a>How can I include expansions of the <TT>__FILE__</TT>and <TT>__LINE__</TT> macrosin a general-purpose debugging macro?</p><hr><p><a href="../index-2.html">top</a></p><p><a href="../questions.html"><img src="../images/buttontop.gif" alt="contents"></a><a href="../search.html"><img src="../images/buttonsrch.gif" alt="search"></a><br><a href="../about.html">about this FAQ list</a> <a href="../eskimo.html">about eskimo</a> <a href="../search.html">search</a> <a href="../feedback.html">feedback</a> <a href="copyright.html">copyright</a><p>Hosted by<a href="http://www.eskimo.com/"><img src="../../www.eskimo.com/img/link/eskitiny.gif" alt="Eskimo North"></a></p></body><!-- Mirrored from c-faq.com/cpp/index.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 07:55:22 GMT --></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -