www.digitalmars.com         C & C++   DMDScript  

D - Possible Error in Comparison Checklist

reply NobodyImportant <NobodyImportant_member pathlink.com> writes:
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++.
Oct 16 2003
parent reply "Matthew Wilson" <matthew stlsoft.org> writes:
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++.
Oct 16 2003
parent reply Andy Friesen <andy ikagames.com> writes:
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.
Oct 16 2003
parent "Walter" <walter digitalmars.com> writes:
"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.
Oct 17 2003