![](https://csdnimg.cn/release/download_crawler_static/76912232/bg7.jpg)
configuration problems, which does not relate to the syntactical correctness, but
the used Cppcheck configuration could be improved.
Possible speedup analysis of template code
Cppcheck instantiates the templates in your code.
If your templates are recursive this can lead to slow analysis that uses a lot of
memory. Cppcheck will write information messages when there are potential
problems.
Example code:
template <int i>
void a()
{
a<i+1>();
}
void foo()
{
a<0>();
}
Cppcheck output:
test.cpp:4:5: information: TemplateSimplifier: max template recursion (100) reached for template 'a<101>'. You might want to limit Cppcheck recursion. [templateRecursion]
a<i+1>();
^
As you can see Cppcheck has instantiated
a<i+1>
until
a<101>
was reached and
then it bails out.
To limit template recursion you can:
• add template specialisation
• configure Cppcheck, which can be done in the GUI project file dialog
Example code with template specialisation:
template <int i>
void a()
{
a<i+1>();
}
void foo()
{
a<0>();
}
6