This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
"macros nested too deep" problem in ss-20000724 (and recent)
- To: gcc-bugs at gcc dot gnu dot org
- Subject: "macros nested too deep" problem in ss-20000724 (and recent)
- From: "Thomas R. Truscott" <trt at cs dot duke dot edu>
- Date: Tue, 25 Jul 2000 18:23:35 -0400 (EDT)
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;
}