Mail Archives: djgpp/2000/01/31/16:39:28
In article <3894DADF DOT 1CAE1543 AT caresystems DOT com DOT au>,
djgpp AT delorie DOT com wrote:
> dennis51 AT my-deja DOT com wrote:
>
> > redir -eo -x -t gxx -O2 -Wall -ftemplate-depth-75 mono.cpp -o
mono.exe
>
> pardon my approach - would anyone know where one can learn in more
detail
> about this template option?
When you install the compiler, you get a program called info.
If you know where to look, info will tell you this:
`-ftemplate-depth-N'
Set the maximum instantiation depth for template classes to N. A
limit on the template instantiation depth is needed to detect
endless recursions during template class instantiation. ANSI/ISO
C++ conforming programs must not rely on a maximum depth greater
than 17.
But, I found out about that option in the best possible way:
I tried to compile with this:
redir -eo -x -t gxx -O2 -Wall mono.cpp -o mono.exe
and I got several error messages that looked like this:
mono.cpp: In function `void search_sub<1, 1, 17>()':
mono.cpp:166: template instantiation depth exceeds maximum of 17
mono.cpp:166: (use -ftemplate-depth-NN to increase the maximum)
mono.cpp:166: instantiating `search_sub<1, 1, 18>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 17>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 16>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 15>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 14>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 13>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 12>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 11>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 10>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 9>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 8>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 7>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 6>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 5>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 4>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 3>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 2>()'
mono.cpp:166: instantiated from `search_sub<1, 1, 1>()'
mono.cpp:216: instantiated from here
This is perhaps the best error message I have ever gotten
out of a compiler.
Note that the error message tells exactly what is wrong, AND
it tells (almost) exactly what to do to fix it.
Who could ask for anything more?
I could ask for less, but I won't.
(There were a total of 850 lines similar to the above.
The program was only 216 lines long. Hmmm, that means that
the last number in the error message above is wrong,
or, at least, misleading.)
Dennis Yelle
Please play with my new Java toy:
http://www.fortunecity.com/roswell/barada/186/chaos/
(If you and your browser ever do that sort of thing.)
Sent via Deja.com http://www.deja.com/
Before you buy.
- Raw text -