# Removal of math.h from VTK headers

**URL:** <https://discourse.vtk.org/t/removal-of-math-h-from-vtk-headers/5163>\
**Category:** Development\
**Created:** [February 9, 2021, 3:41pm UTC](https://discourse.vtk.org/t/removal-of-math-h-from-vtk-headers/5163 "2021-02-09T15:41:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [February 9, 2021, 3:41pm UTC](https://discourse.vtk.org/t/removal-of-math-h-from-vtk-headers/5163/1 "2021-02-09T15:41:00Z")

</div>

In [!7572](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7572), I remove `#include <math.h>` from vtkSetGet.h (which is included by all VTK class headers). The reason for the removal is modernization of the code, but of course it will cause some (easily fixed) compile errors in apps and libraries that use VTK.

Do people have any opinions on the best time to merge this change?

---

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)\
**Post date:** [February 9, 2021, 5:16pm UTC](https://discourse.vtk.org/t/removal-of-math-h-from-vtk-headers/5163/2 "2021-02-09T17:16:32Z")

</div>

Thanks for asking. The change has a good reason and can only cause a tiny inconvenience, so I don’t think any developer would complain.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [February 9, 2021, 5:25pm UTC](https://discourse.vtk.org/t/removal-of-math-h-from-vtk-headers/5163/3 "2021-02-09T17:25:44Z")

</div>

I think “small” inconvenience, but not quite “tiny” 😉

For example it required the addition of `#include <cmath>` to around 20 .cxx files in Paraview, and will probably require a similar number of changes in Slicer.

---

<div class="post-metadata">

**Author:** ![olesenm](https://discourse.vtk.org/user_avatar/discourse.vtk.org/olesenm/32/10443_2.png) [@olesenm](https://discourse.vtk.org/u/olesenm)\
**Post date:** [February 9, 2021, 9:29pm UTC](https://discourse.vtk.org/t/removal-of-math-h-from-vtk-headers/5163/4 "2021-02-09T21:29:08Z")

</div>

@dgobbi - if anything, the change was overdue. Modernizing code, but also not including gratuitous includes in places where they don’t make sense.

+1 💚

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [February 9, 2021, 10:29pm UTC](https://discourse.vtk.org/t/removal-of-math-h-from-vtk-headers/5163/5 "2021-02-09T22:29:46Z")

</div>

I should add that one of my reasons for the change is that it hides math.h from the wrappers. The handling of system & compiler includes by the wrappers is imperfect, so moving them into the .cxx files where the wrappers don’t see them makes wrapping more robust.

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [February 10, 2021, 7:43pm UTC](https://discourse.vtk.org/t/removal-of-math-h-from-vtk-headers/5163/6 "2021-02-10T19:43:50Z")

</div>

This change seems to have support, so I’ll merge tonight unless there are objections.
