title: Functions inside functions in C
body: <p>I'm making a code that is similar to this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  double some_function( double x, double y)
  {
    double inner_function(double x)
    { 
      // some code
      return x*x;
    }
  
    double z;
    z = inner_function(x);
    return z+y;
  
  }
  
  int main(void)
  {
    printf("%f\n", some_function(2.0, 4.0));
    return 0;
  }
  </code></pre>
  
  <p>This compiles perfectly in GCC (with no warnings) but fails to compile in ICC. </p>
  
  <p>ICC gives:</p>
  
  <pre><code>main.c(16): error: expected a ";"
      { 
      ^
  
  main.c(21): warning #12: parsing restarts here after previous syntax error
      double z;
              ^
  
  main.c(22): error: identifier "z" is undefined
      z = inner_function(x);
      ^
  
  compilation aborted for main.c (code 2)
  </code></pre>
  
  <p>What am I doing wrong? </p>
  
  <p>Thanks.</p>
  
  <p>(edit) Sorry for the poor example. In my original code I kinda need to do this stuff. I'm using a GSL numerical integrator and have something like:</p>
  
  <pre><code>double stuff(double a, double b)
  {
    struct parameters
    {
      double a, b;
    };
  
    double f(double x, void * params)
    {
      struct parameters p = (struct parameters *) params;
      double a = p-&gt;a, b = b-&gt;b;
      return some_expression_involving(a,b,x);
    }
    struct parameters par = {a,b};
  
    integrate(&amp;f, &amp;par);
  
  }
  </code></pre>
  
  <p>And I have lots of functions with this kind of structure: they are the result of an integration of a functions with lots of external parameters. And the functions that implements numerical integration must receive a pointer to a function of type: </p>
  
  <pre><code>double f(double x, void * par)
  </code></pre>
  
  <p>I would really like functions to be nested this way so my code doesn't bloat with lots and lots of functions. And I hope I could compile it with ICC to speed things a bit.</p>