memnus: Dragon with pigtails and glasses, saying "No sense... in a way that blows your mind?" (That makes no sense! (O&M))
Brian ([personal profile] memnus) wrote2005-11-05 03:28 pm

C/C++ issues

The code I'm trying to port (UNIX->Windows) is an extreme fan of this convention:

void function()
{
  int variable, othervariable;

  int otherfunction(arguments)
  {
    doStuff(arguments);
    doDifferentStuff(variable, othervariable);
    return result;
  }

  doSomethingElse(otherfunction);
}


Visual Studio flips out and cries when this happens; the very same code compiled happily in GCC under Cygwin. I saw something somewhere that declaring functions inside other functions is strictly forbidden in C; is this true? Does GCC waive this little restriction? Is there anything else I can do about this than make the function and the variable global? I suppose I could make a struct that has those variables within it, add that as an argument to otherfunction and everything else that's ever aware of it, but that sounds like a royal pain. Is there a setting somewhere that makes this possible again?

click

Post a comment in response:

If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org