This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

"macros nested too deep" problem in ss-20000724 (and recent)


Starting sometime this year (and including ss-20000724),
the pre-processor has had a nested macro limit of about 200.
Before that it had a limit of about 400.
The smaller limit causes a number of compile failures
in a large software product:
    ... macros nested too deep invoking ...

Our fix was is to increase CPP_STACK_MAX in cpplib.h
	#define CPP_STACK_MAX 1000
Perhaps that is good enough.

I think the only reason for the limit is to detect recursion,
in which case it would be (theoretically) cleaner
for cpp to detect that directly,
e.g. by marking the macros that it is currently expanding.

Tom Truscott

P.S. here is a program "genn.c" that demos the problem.
/*    make genn; genn 500 > foo.c; gcc foo.c */
main(int argc, char *argv[])
{
   int i, n;

   n  = ( argc > 1 )? atoi(argv[1]): 5;
   printf("#define sym000 0\n");
   for (i = 1; i < n; i++)
      printf("#define sym%03d sym%03d\n", i, i-1);
   printf("int main(){return sym%03d;}\n", i-1);
   return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]