Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>VALUE</code> is defined as <code>SUBSTITUTE</code>. The definition of <code>VALUE</code> is not aware at any point that <code>SUBSTITUTE</code> has also been defined. After <code>VALUE</code> is replaced, whatever it was replaced by will be scanned again, and potentially more replacements applied then. All <code>define</code>s exist in their own conceptual space, completely unaware of each other; they <em>only</em> interact with one another at the site of expansion in the main program text (<code>define</code>s are directives, and thus not part of the program proper).</p> <p>The rules for the preprocessor are specified alongside the rules for C proper in the language standard. The standard documents themselves cost money, but you can usually download the "final draft" for free; the latest (C11) can be found here: <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf" rel="nofollow noreferrer">http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf</a></p> <p>For at-home use the draft is pretty much equivalent to the real thing. Most people who quote the standard are actually looking at copies of the draft. (Certainly it's closer to the actual standard than any real-world C compiler is...)</p> <p>There's a more accessible description of the macro rules in the GCC manual: <a href="http://gcc.gnu.org/onlinedocs/cpp/Self_002dReferential-Macros.html" rel="nofollow noreferrer">http://gcc.gnu.org/onlinedocs/cpp/Self_002dReferential-Macros.html</a> </p> <hr> <p>Additionally... I couldn't tell you much about the Boost preprocessor library, not having used it, but there's a beautiful pair of libraries by the same authors called <a href="http://rosettacode.org/wiki/Order" rel="nofollow noreferrer">Order and Chaos</a> that are very "clean" (as macro code goes) and easy to understand. They're more academic in tone and intended to be pure rather than portable; which <em>might</em> make them easier reading.</p> <p>(Since I don't know Boost PP I don't know how relevant this is to your question <em>but</em>) there's also a good introductory example of the kids of techniques these libraries use for advanced metaprogramming constructs in this answer: <a href="https://stackoverflow.com/questions/3136686/is-the-c99-preprocessor-turing-complete">Is the C99 preprocessor Turing complete?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload