Page MenuHomePhabricator

Clean up includes
Closed, WontfixPublic

Description

As a more broad issue than T12407: Clean up includes of MITK core, it is favorable for speeding up compile time to use Forward declarations, move includes to cpp file and remove unnecessary includes.

  • There is a clang-based tool for that: Include what you use
  • Also, there is a python tool for that (some false positives the last time I tried it): Cppclean

Event Timeline

I did just run include what you use on MitkCore and accepted the suggested changes. This results in a number of errors like

mitkPlaneGeometryDataToSurfaceFilter.cpp:111:22: error: unknown type name 'AbstractTransformGeometry'
mitkPlaneGeometryDataToSurfaceFilter.cpp:118:32: error: no member named 'GetPlane' in 'mitk::PlaneGeometry'
mitkCoreObjectFactory.cpp:194:27: error: no member named 'PlaneGeometryDataVtkMapper3D' in namespace 'mitk'; did you mean 'PlaneGeometryDataMapper2D'?
mitkCoreObjectFactory.cpp:80:7: error: deleting pointer to incomplete type 'mitk::LegacyFileReaderService' may cause undefined behavior
mitkOperationEvent.cpp:106:30: error: 'OperationEvent' does not refer to a value
mitkSurfaceToSurfaceFilter.cpp:75:23: error: member access into incomplete type 'OutputType' (aka 'mitk::Surface')
mitkRenderingManager.cpp:293:64: error: too many arguments to function call, expected single argument '_arg', have 2 arguments
error: "Do not include itkExceptionObject.h directly,  include itkMacro.h instead."

and so on and so on, this will probably be more of a "look at the suggestions offered by include what you use and think about them" than any kind of automatism. Probably not worth the effort. I am going to try CppClean instead.

I used CppClean about 2 years ago and it was also quite some manual effort to delete unused includes. Maybe, it has improved in the meantime.

Seems to be a lot of manual effort as well you have to extract all include paths (from e.g. the CMakeFiles/ModuleName.dir/flags.make). Call it on the source directory with these paths and manually integrate the suggestions offered.

goch lowered the priority of this task from Low to Wishlist.
goch added a subscriber: goch.
goch claimed this task.