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 - #elif</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/_23define.html"><img src="../../../images/prev.gif" hspace="3" border="0" alt="previous" >#define</a> <br /> </td> <td align="right" valign="middle"> <a href="../../ex/cpp_3A_3A/_23else.html">#else<img src="../../../images/next.gif" hspace="3" border="0" alt="next" ></a> <br /> </td> </tr> </table> <h1>Directive #elif</h1> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Directive</span> <span class='homogen--name'><b>#elif</b></span> </dt> <dd><p><code class='directive'>#if</code><br> <code class='directive'>#elif</code><br> <code class='directive'>#elseif</code><br> <code class='directive'>#else</code><br> <code class='directive'>#endif</code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'> <p>The #if directive causes conditional compiling of code depending on the expression after the #if directive. That is, if the expression is true, the code up to the next #else, #elif, #elseif or #endif is compiled. If the expression is false, that code will be skipped. If the skip leads up to a #else, the code after the else will be compiled. #elif and #elseif are equivialent and causes the code that follow them to be compiled if the previous #if or #elif evaluated false and the expression after the #elif evaluates true. </p> <p>Expressions given to #if, #elif or #endif are special, all identifiers evaluate to zero unless they are defined to something else. Integers,
d8215a1996-09-22Fredrik Hübinette (Hubbe) strings and floats are the only types that can be used, but all pike
a44f221996-02-24Fredrik Hübinette (Hubbe) operators can be used on these types. </p>
d8215a1996-09-22Fredrik Hübinette (Hubbe) <p>Also, two special functions can be used, defined() and constant().
a44f221996-02-24Fredrik Hübinette (Hubbe) defined(&lt;identifer&gt;) expands to '1' if the identifier is defined,
d8215a1996-09-22Fredrik Hübinette (Hubbe) '0' otherwise. constant(&lt;identifier&gt;) expands to '1' if identifer is an predefined constant (with add_constant), '0' otherwise.</p>
a44f221996-02-24Fredrik Hübinette (Hubbe) </dd> <dt class='head--doc'>Example</dt> <dd class='example'><pre> <tt><p>#if 1<br /> <dl class='group--doc'><dd>write("foo");<br /> </dd> </dl>#else<br /> <dl class='group--doc'><dd>write("bar");<br /> </dd> </dl>#endif<br /> </p> <p>#if defined(FOO)<br /> <dl class='group--doc'><dd>write(FOO);<br /> </dd> </dl>#elif defined(BAR)<br /> <dl class='group--doc'><dd>write(BAR);<br /> </dd> </dl>#else<br /> <dl class='group--doc'><dd>write("default");<br /> </dd> </dl>#endif<br /> </p>
d8215a1996-09-22Fredrik Hübinette (Hubbe) <p>#if !constant(write_file)<br /> inherit "simulate.pike"<br />
a44f221996-02-24Fredrik Hübinette (Hubbe) #endif<br /> <br /> </p> </tt></pre></dd></dl> <hr size='1' noshade='1' /> </td> </tr> </table> </body> <script>PikeDoc.current = {"link":"ex/cpp_3A_3A/_23elif.html","name":"#elif"};</script> <script src='../../ex/cpp_3A_3A/index.js'></script> <script src='../../ex/cpp_3A_3A/load_index.js'></script> </html>