Thread overview
Possible Error in Comparison Checklist
Oct 16, 2003
NobodyImportant
Oct 16, 2003
Matthew Wilson
Oct 17, 2003
Andy Friesen
Oct 17, 2003
Walter
October 16, 2003
I could be wrong, but I'm pretty sure that C++, and probably C as well, supports nested functions.  This may or may not be ANSI, but I'm almost positive that g++ supports it.  Perhaps you should look into that, or at least offer some sort of clarification a la the resizable arrays for C++.


October 16, 2003
Well, first, neither C or C++ support nested functions.

Whether GCC does, I've never heard of it (not that that means terribly much
;))

I've just tried the following:


#include <stdio.h>

int main()
{
  int add(int i)
  {
    return 1 + i;
  }

  int i = add(10);

  printf("%d => %d\n", 10, i);

  return 0;
}

and it does not work with GCC 3.2. Is this the kind of thing you're talking about? Are there compiler flags I should be using?

btw, D's nested functions carry with them the context of their enclosing scope, so that variables in that scope are accessible in the nested function. Is that the case with GCC? It'd be very interesting if so.

Matthew


"NobodyImportant" <NobodyImportant_member@pathlink.com> wrote in message news:bmn558$1kkp$1@digitaldaemon.com...
> I could be wrong, but I'm pretty sure that C++, and probably C as well,
supports
> nested functions.  This may or may not be ANSI, but I'm almost positive
that g++
> supports it.  Perhaps you should look into that, or at least offer some
sort of
> clarification a la the resizable arrays for C++.
>
>



October 17, 2003
Matthew Wilson wrote:
> Well, first, neither C or C++ support nested functions.
> 
> Whether GCC does, I've never heard of it (not that that means terribly much
> ;))
> 

I used this several times way back in my DJGPP days without even realizing it.  I don't know if newer versions of GCC support it, but the really old ones apparently do.

October 17, 2003
"Andy Friesen" <andy@ikagames.com> wrote in message news:bmndp6$1vui$1@digitaldaemon.com...
> Matthew Wilson wrote:
> > Well, first, neither C or C++ support nested functions.
> >
> > Whether GCC does, I've never heard of it (not that that means terribly
much
> > ;))
> >
>
> I used this several times way back in my DJGPP days without even realizing it.  I don't know if newer versions of GCC support it, but the really old ones apparently do.

GCC apparently does support nested functions, but G++ does not. In any case, it is not part of standard C nor C++, and no other C/C++ compiler I know of supports it.