title: Anonymous functions using GCC statement expressions
body: <p>This question isn't terribly specific; <strong>it's really for my own C enrichment and I hope others can find it useful as well.</strong></p>
  
  <p>Disclaimer: I know many will have the impulse to respond with "if you're trying to do FP then just use a functional language". I work in an embedded environment that needs to link to many other C libraries, and doesn't have much space for many more large shared libs and does not support many language runtimes. Moreover, dynamic memory allocation is out of the question. I'm also just really curious.</p>
  
  <p>Many of us have seen this nifty C macro for lambda expressions:</p>
  
  <pre><code>#define lambda(return_type, function_body) \
  ({ \
        return_type __fn__ function_body \
            __fn__; \
  })
  </code></pre>
  
  <p>And an example usage is:</p>
  
  <pre><code>int (*max)(int, int) = lambda (int, (int x, int y) { return x &gt; y ? x : y; });
  max(4, 5); // Example
  </code></pre>
  
  <p>Using <code>gcc -std=c89 -E test.c</code>, the lambda expands to:</p>
  
  <pre><code>int (*max)(int, int) = ({ int __fn__ (int x, int y) { return x &gt; y ? x : y; } __fn__; });
  </code></pre>
  
  <p>So, these are my questions:</p>
  
  <ol>
  <li><p>What precisely does the line <em>int (*X);</em> declare? Of course, <em>int * X;</em> is a pointer to an integer, but how do these two differ?</p></li>
  <li><p>Taking a look at the exapnded macro, what on earth does the final <code>__fn__</code> do? If I write a test function <code>void test() { printf("hello"); } test;</code> - that immediately throws an error. I do not understand that syntax.</p></li>
  <li><p>What does this mean for debugging? (I'm planning to experiment myself with this and gdb, but others' experiences or opinions would be great). Would this screw up static analyzers?</p></li>
  </ol>