# Need help to fix some -Wunused-template dashboard warnings

**URL:** https://discourse.itk.org/t/need-help-to-fix-some-wunused-template-dashboard-warnings/357
**Category:** Engineering
**Created:** [October 25, 2017, 3:51pm UTC](https://discourse.itk.org/t/need-help-to-fix-some-wunused-template-dashboard-warnings/357 "2017-10-25T15:51:39Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [October 25, 2017, 3:51pm UTC](https://discourse.itk.org/t/need-help-to-fix-some-wunused-template-dashboard-warnings/357/1 "2017-10-25T15:51:39Z")

</div>

Hi all,

Any C++ experts out there that could help fix these 2 warnings:

ITK/Modules/Core/Common/include/itkMath.h:524:1: warning: unused function template ‘AlmostEqualsScalarComparer’ [-Wunused-template]  
AlmostEqualsScalarComparer( TScalarType1 x1, TScalarType2 x2 )  
^

ITK/Modules/Core/Common/include/itkVersor.hxx:590:28: warning: unused function template ‘localTransformVectorMath’ [-Wunused-template]  
const OutputVectorType localTransformVectorMath(const InputVectorType & VectorObject,  
^

I think it has something to do with ODR violation checking, but I’m no C++ expert…

Thanks,

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [October 25, 2017, 3:58pm UTC](https://discourse.itk.org/t/need-help-to-fix-some-wunused-template-dashboard-warnings/357/2 "2017-10-25T15:58:02Z")

</div>

I believe I have seen this warning before with “static” template functions and template functions in anonymous namespaces. If the static key word is removed then the warning goes away. You could still specify hidden linkage if really needed.

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [October 25, 2017, 7:52pm UTC](https://discourse.itk.org/t/need-help-to-fix-some-wunused-template-dashboard-warnings/357/3 "2017-10-25T19:52:46Z")

</div>

Some of them are static, and some are not. Those that are not all seem to be in anonymous namespaces…

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [October 26, 2017, 2:27pm UTC](https://discourse.itk.org/t/need-help-to-fix-some-wunused-template-dashboard-warnings/357/4 "2017-10-26T14:27:10Z")

</div>

Do you have a simple example that reproduces these warnings that you could share?

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [October 26, 2017, 2:43pm UTC](https://discourse.itk.org/t/need-help-to-fix-some-wunused-template-dashboard-warnings/357/5 "2017-10-26T14:43:11Z")

</div>

Looking at the history of the file where I struggled with this warning there were a couple different issues that may have been causing problem. I believe this patch was the one that addressed the warning for me:

> <https://github.com/SimpleITK/SimpleITK/commit/962d464baa8b5812280ace9df1ba4faed4a62e7c#diff-2de8f4a5f7f320b4f5aa7b724d7ece82>

Contrary to what I initially said, this appear to have added the ‘inline’ keyword to the function.

---

<div class="post-metadata">

### Author: ![seanm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.itk.org/u/seanm)
#### Post date: [October 27, 2017, 4:27pm UTC](https://discourse.itk.org/t/need-help-to-fix-some-wunused-template-dashboard-warnings/357/6 "2017-10-27T16:27:48Z")

</div>

You mean something stripped down? No, I don’t. I’m trying to get my dashboards green, and there are a few -Wunused-template warnings, see:

[https://open.cdash.org/viewBuildError.php?type=1&buildid=5118773](https://open.cdash.org/viewBuildError.php?type=1&buildid=5118773)

Cheers,

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [November 8, 2017, 6:11pm UTC](https://discourse.itk.org/t/need-help-to-fix-some-wunused-template-dashboard-warnings/357/7 "2017-11-08T18:11:43Z")

</div>

From this stackoverflow question: [c++ - Suppress Compiler warning Function declared never referenced - Stack Overflow](https://stackoverflow.com/questions/11124895/suppress-compiler-warning-function-declared-never-referenced)

I see two answers that are very interesting: The first one:

> -Wunused-function  
> Warn whenever a static function is declared but not defined or a non-inline static function is unused. This warning is enabled by -Wall.

Which is followed by the comment:

> static inline doesn’t (always) suppress this for clang. – robertwb Nov 16 '16 at 0:52

From your dashboard result, I see that you are using `clang`, which might explain why the solution given by @blowekamp does solve the issue completely.

Now there is another solution that I think is interesting for this question:

> void foo (int, int) **attribute** ((unused));

It would be interesting to set this attribute and see if that solves your issue. We could then create a patch for ITK if that works.
