As the title says, is there any compiler logging settings which provides the max instantation deph reached by the compiler during compilation?
如标题所示,是否有任何编译器日志设置,提供编译器在编译过程中所达到的最大实例化deph值?
If the compilation exceds the max template deph (Which GCC's default value is 900 in C++11 mode), compilation fails. But what I need is to get the maximum template instantation depth which the compiler has reached during a successfull compilation.
如果编译超过了最大模板deph(在c++ 11模式下GCC的默认值是900),编译将失败。但是我需要的是获得编译器在成功编译期间达到的最大模板实例深度。
1 个解决方案
#1
7
g++
does have such an option, but it isn't enabled by default on kubuntu, for example.
g++确实有这样的选项,但是在kubuntu中没有启用它。
The following is part of gcc/cp/tree.c
from gcc-4.8.1
(and is therefore licensed under the GPL):
下面是gcc/cp/tree的一部分。c从gcc-4.8.1(因此在GPL许可下):
void
cxx_print_statistics (void)
{
print_search_statistics ();
print_class_statistics ();
print_template_statistics ();
if (GATHER_STATISTICS)
fprintf (stderr, "maximum template instantiation depth reached: %d\n",
depth_reached);
}
You can get those statistics when adding -fdump-statistics -fstats
to your command line, but GATHER_STATISTICS
has to be enabled at the time you compile gcc
, so you will probably have to rebuild gcc
in order to get the functionality you are looking for.
您可以在向命令行添加-fdump-statistics -fstats时获得这些统计信息,但是在编译gcc时必须启用采集区统计信息,因此您可能需要重新构建gcc,以便获得您正在寻找的功能。
#1
7
g++
does have such an option, but it isn't enabled by default on kubuntu, for example.
g++确实有这样的选项,但是在kubuntu中没有启用它。
The following is part of gcc/cp/tree.c
from gcc-4.8.1
(and is therefore licensed under the GPL):
下面是gcc/cp/tree的一部分。c从gcc-4.8.1(因此在GPL许可下):
void
cxx_print_statistics (void)
{
print_search_statistics ();
print_class_statistics ();
print_template_statistics ();
if (GATHER_STATISTICS)
fprintf (stderr, "maximum template instantiation depth reached: %d\n",
depth_reached);
}
You can get those statistics when adding -fdump-statistics -fstats
to your command line, but GATHER_STATISTICS
has to be enabled at the time you compile gcc
, so you will probably have to rebuild gcc
in order to get the functionality you are looking for.
您可以在向命令行添加-fdump-statistics -fstats时获得这些统计信息,但是在编译gcc时必须启用采集区统计信息,因此您可能需要重新构建gcc,以便获得您正在寻找的功能。