Syntax question

Why is this legal in C and not in C++?

void loop ()
{
  uint8 myVal;
  uint8 myFunction (uint8 myParam)
  {
    uint8 myReturn;
    // blah blah some bit-fiddling on "myParam"
    return myReturn;
  }
 ...
 ...
 newVal = myFunction (0x18);
}

Visual C doesn't like it.

Does myFunction work correctly?

Hi Groove,

Why is this legal in C and not in C++?

Who says that local functions are legal in C?

For C++ you can find a good discussion of a workaround here:
http://www.gotw.ca/gotw/058.htm

MikeT

That's not legal C, however gcc does as one of its extensions to C implement nested functions.

http://www.cse.msu.edu/cgi-bin/info2html?%28gcc%29Nested%20Functions

I really like gcc. :)