a44f221996-02-24Fredrik Hübinette (Hubbe) <html><head> <style type='text/css'> svg line { stroke:#343434; stroke-width:2; } svg text { fill:#343434; } svg a { fill:#0768b2; text-decoration: underline; } </style> <title>Pike Reference Manual - #define</title> <link rel='stylesheet' href='../../style.css' /></head> <body topmargin='0' leftmargin='0' marginheight='0' marginwidth='0' bgcolor='#ffffff' text='#000000' link='#000099' alink='#002040' vlink='#000099'> <table widht="100%"> <tr> <td colspan='3'></td> <td colspan='2' align='right'>Extracted from at .</td> </tr> <tr> <td width="0%"><img src="../../../images/unit.gif" alt="" width="10" height="1"></td> <td width="1%"> <a href="http://pike.lysator.liu.se/"><img src="../../../images/pike_logo.gif" border="0" alt="pike.lysator.liu.se" width="181" height="41" hspace="5"></a></td> <td width="0%"><img src="../../../images/unit.gif" alt="" width="10" height="1"></td> <td width="99%"> <table align="center" border="0" width="100%" cellspacing="0" cellpadding="0" valign="center"> <tr> <td width="1%"> <img src="../../../images/pike_line_left.gif" alt="" border="0" width="5" height="11"> </td> <td background="../../../images/pike_line_middle.gif" width="98%"> <img src="../../../images/unit.gif" alt="" border="0" width="11" height="11"> </td> <td width="1%"> <img src="../../../images/pike_line_right.gif" alt="" border="0" width="5" height="11"> </td> </tr> </table> </td> <td width="0%"><img src="../../../images/unit.gif" alt="" width="10" height="1"></td> </tr> <tr> <td colspan="5"><img src="../../../images/unit.gif" alt="" width="1" height="10"></td> </tr> </table> <table> <tr> <td width='180' valign='top' bgcolor='#f0f0f0'><a href='../../index.html'><b class='top head'>Top</b></a> <a href='../../ex/cpp_3A_3A.html'><b class='head'>cpp::</b></a> <script></script> <noscript> <div class='sidebar'> <a href='../../ex/cpp_3A_3A/index.html'><b>Symbol index</b></a><br /> </div> </noscript> </td> <td width='520' valign='top'> <table border="0" width="520" bgcolor="#e0e0e0" cellpadding="0" cellspacing="4" class='sidebar'> <tr> <td valign="middle"> <a href="../../ex/cpp_3A_3A/_23_21.html"><img src="../../../images/prev.gif" hspace="3" border="0" alt="previous" >#!</a> <br /> </td> <td align="right" valign="middle"> <a href="../../ex/cpp_3A_3A/_23elif.html">#elif<img src="../../../images/next.gif" hspace="3" border="0" alt="next" ></a> <br /> </td> </tr> </table> <h1>Directive #define</h1> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Directive</span> <span class='homogen--name'><b>#define</b></span> </dt> <dd><p><code class='directive'>#define</code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'> <p>The simplest way to use define is to write </p> <p><dl class='group--doc'><dd>#define &lt;identifier&gt; &lt;replacement string&gt;<br /> </dd> </dl> </p> <p>which will cause all subsequent occurances of 'identifier' to be replaced with the replacement string. </p> <p>Define also has the capability to use arguments, thus a line like </p> <p><dl class='group--doc'><dd>#define &lt;identifier&gt;(arg1, arg2) &lt;replacement string&gt;<br /> </dd> </dl> </p> <p>would cause identifer to be a macro. All occurances of 'identifier(something1,something2d)' would be replaced with the replacement string. And in the replacement string, arg1 and arg2
563f981996-08-15Fredrik Hübinette (Hubbe) will be replaced with something1 and something2.</p> </dd> <dt class='head--doc'>Bugs</dt> <dd class='body--doc'> <p>Note that it is not a good idea to do something like this: </p> <p>#define foo bar // a comment </p> <p>The comment will be included in the define, and thus inserted in the code. This will have the effect that the rest of the line will be ignored when the word foo is used. Not exactly what you might expect.
a44f221996-02-24Fredrik Hübinette (Hubbe) </p>
563f981996-08-15Fredrik Hübinette (Hubbe) <p></p>
a44f221996-02-24Fredrik Hübinette (Hubbe) </dd></dl> <hr size='1' noshade='1' /> </td> </tr> </table> </body> <script>PikeDoc.current = {"link":"ex/cpp_3A_3A/_23define.html","name":"#define"};</script> <script src='../../ex/cpp_3A_3A/index.js'></script> <script src='../../ex/cpp_3A_3A/load_index.js'></script> </html>