diff --git a/README/ReleaseNotes/v642/index.md b/README/ReleaseNotes/v642/index.md index ccea5f564c7b0..e86f6c3cb13b4 100644 --- a/README/ReleaseNotes/v642/index.md +++ b/README/ReleaseNotes/v642/index.md @@ -85,6 +85,14 @@ The `TMVA_SOFIE_GNN` tutorials have been migrated to this workflow and produce i ## Build System +### Optimization of ROOT header files + +In ROOT 6.22, many (but not all) unused includes were removed from ROOT header files. The remaining unused includes are now removed in ROOT 6.42. +For instance, `#include "TBuffer.h"` was removed from `TKey.h`. This change may cause errors during compilation of ROOT-based code if one was implicitly relying on this transitive include on downstream code using TBuffer without actually including `TBuffer.h`. Another example: `TStyle.h` no longer includes internally `TArrayI.h`. +To fix it in downstream code, provide the missing includes if you were using those classes from transitive includes without explicitly including them. +This improves compile times and reduces code inter-dependency; see https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md for a good overview of the motivation. +The macro `R__LESS_INCLUDES` no longer has an effect since it's the new default behavior. + ### Moving from builtin dependencies to system-provided packages * The general direction of the ROOT project is to become more and more reliant on system packages. It is *recommended* to make the packages required by ROOT available on the system, e.g. via a package manager, and not with the builtin mechanism. This allows for timely updates and reduces the size of the installed binaries. diff --git a/cmake/modules/RootConfiguration.cmake b/cmake/modules/RootConfiguration.cmake index 7055457189e9d..9064d5e5770be 100644 --- a/cmake/modules/RootConfiguration.cmake +++ b/cmake/modules/RootConfiguration.cmake @@ -388,11 +388,6 @@ if(dataframe) else() set(hasdataframe undef) endif() -if(dev) - set(use_less_includes define) -else() - set(use_less_includes undef) -endif() if(root7) set(hasroot7 define) else() diff --git a/config/RConfigure.in b/config/RConfigure.in index 2b2370256b4ed..2218b73bcbe89 100644 --- a/config/RConfigure.in +++ b/config/RConfigure.in @@ -51,7 +51,6 @@ #@hascurl@ R__HAS_CURL /**/ #@hasdataframe@ R__HAS_DATAFRAME /**/ #@hasroot7@ R__HAS_ROOT7 /**/ -#@use_less_includes@ R__LESS_INCLUDES /**/ #define R__HARDWARE_INTERFERENCE_SIZE @hardwareinterferencesize@ /*Determined at CMake configure to be stable across all TUs*/ #@usezlibng@ R__HAS_ZLIB_NG /**/ diff --git a/core/base/inc/Rtypes.h b/core/base/inc/Rtypes.h index f76760d381178..a64824a82f886 100644 --- a/core/base/inc/Rtypes.h +++ b/core/base/inc/Rtypes.h @@ -23,13 +23,6 @@ #include "RtypesCore.h" // #include "DllImport.h" // included via RtypesCore.h, not used here -#ifndef R__LESS_INCLUDES -#include -#include "strtok.h" // provides R__STRTOK_R with include -#include "strlcpy.h" // part of string.h on systems that have it -#include -#endif - #include #include diff --git a/core/base/inc/TDirectory.h b/core/base/inc/TDirectory.h index 744848ae72948..b4f2017b19097 100644 --- a/core/base/inc/TDirectory.h +++ b/core/base/inc/TDirectory.h @@ -26,14 +26,7 @@ #include "TUUID.h" #include -#ifdef R__LESS_INCLUDES class TList; -#else -#include "TList.h" -#include "TBuffer.h" -// #include "TDatime.h" -#endif - class TBrowser; class TKey; class TFile; diff --git a/core/base/inc/TFileInfo.h b/core/base/inc/TFileInfo.h index c6f7f81493b55..1df66393ae20f 100644 --- a/core/base/inc/TFileInfo.h +++ b/core/base/inc/TFileInfo.h @@ -23,16 +23,9 @@ #include "TNamed.h" #include "TList.h" -#ifdef R__LESS_INCLUDES class TUrl; class TUUID; class TMD5; -#else -#include "TUrl.h" -#include "TUUID.h" -#include "TMD5.h" -#endif - class TFileInfoMeta; diff --git a/core/base/inc/TProcessID.h b/core/base/inc/TProcessID.h index 6eeac0991bccb..06fad0c092639 100644 --- a/core/base/inc/TProcessID.h +++ b/core/base/inc/TProcessID.h @@ -24,15 +24,10 @@ #include "TNamed.h" -#ifdef R__LESS_INCLUDES -class TObjArray; -#else -#include "TObjArray.h" -#endif - #include #include +class TObjArray; class TExMap; namespace ROOT { diff --git a/core/base/inc/TStyle.h b/core/base/inc/TStyle.h index 4dc3dff2f4fd4..410f5b61a88ec 100644 --- a/core/base/inc/TStyle.h +++ b/core/base/inc/TStyle.h @@ -20,10 +20,6 @@ #include "TAttAxis.h" #include "TColor.h" -#ifndef R__LESS_INCLUDES -#include "TArrayI.h" -#endif - class TBrowser; class TStyle : public TNamed, public TAttLine, public TAttFill, public TAttMarker, public TAttText { diff --git a/core/base/inc/TTask.h b/core/base/inc/TTask.h index d936ea828f09d..53aa024da7930 100644 --- a/core/base/inc/TTask.h +++ b/core/base/inc/TTask.h @@ -23,15 +23,9 @@ #include "TNamed.h" -#ifdef R__LESS_INCLUDES class TList; -#else -#include "TList.h" -#endif - class TBrowser; - class TTask : public TNamed { protected: diff --git a/core/base/inc/TVirtualMonitoring.h b/core/base/inc/TVirtualMonitoring.h index 65b3edb482ccf..7b3a2681d51d3 100644 --- a/core/base/inc/TVirtualMonitoring.h +++ b/core/base/inc/TVirtualMonitoring.h @@ -22,14 +22,8 @@ #include "TNamed.h" -#ifdef R__LESS_INCLUDES class TList; class TMap; -#else -#include "TList.h" -#include "TMap.h" -#endif - class TFile; class TVirtualMonitoringWriter : public TNamed { diff --git a/core/foundation/inc/RtypesCore.h b/core/foundation/inc/RtypesCore.h index cb2a8295eface..b4ac77a1a4626 100644 --- a/core/foundation/inc/RtypesCore.h +++ b/core/foundation/inc/RtypesCore.h @@ -38,10 +38,6 @@ #include "DllImport.h" -#ifndef R__LESS_INCLUDES -#include // size_t, NULL -#endif - //---- Tag used by rootcling to determine constructor used for I/O. class TRootIOCtor; diff --git a/core/gui/inc/TContextMenu.h b/core/gui/inc/TContextMenu.h index 4e81f0278788b..d5d1822179f2d 100644 --- a/core/gui/inc/TContextMenu.h +++ b/core/gui/inc/TContextMenu.h @@ -15,12 +15,7 @@ #include "TNamed.h" -#ifdef R__LESS_INCLUDES class TContextMenuImp; -#else -#include "TContextMenuImp.h" -#endif - class TMethod; class TFunction; class TMethodArg; diff --git a/core/gui/inc/TToggle.h b/core/gui/inc/TToggle.h index 045fe1cedbfba..514b2f5c81e71 100644 --- a/core/gui/inc/TToggle.h +++ b/core/gui/inc/TToggle.h @@ -36,13 +36,8 @@ #include "TNamed.h" -#ifdef R__LESS_INCLUDES class TMethodCall; class TMethod; -#else -#include "TMethodCall.h" -#include "TMethod.h" -#endif class TToggle: public TNamed { diff --git a/core/meta/inc/TClass.h b/core/meta/inc/TClass.h index 38f68c3b083dd..ddc15236a9b0c 100644 --- a/core/meta/inc/TClass.h +++ b/core/meta/inc/TClass.h @@ -24,16 +24,6 @@ #include "TString.h" #include "TSchemaRule.h" -#ifdef R__LESS_INCLUDES -class TObjArray; -#else -#include "TObjArray.h" -// Not used in this header file; user code should #include this directly. -// #include "TObjString.h" -// #include "ThreadLocalStorage.h" -// #include -#endif - #include #include #include @@ -42,6 +32,7 @@ class TObjArray; #include #include +class TObjArray; class TBaseClass; class TBrowser; class TDataMember; diff --git a/core/meta/inc/TMethodArg.h b/core/meta/inc/TMethodArg.h index 20ad4e80ae9cd..c7d42af7624af 100644 --- a/core/meta/inc/TMethodArg.h +++ b/core/meta/inc/TMethodArg.h @@ -24,12 +24,7 @@ #include "TDictionary.h" #include -#ifdef R__LESS_INCLUDES class TDataMember; -#else -#include "TDataMember.h" -#endif - class TFunction; class TMethod; diff --git a/core/meta/inc/TProtoClass.h b/core/meta/inc/TProtoClass.h index f3f05b3e19a6f..6807b16d53c64 100644 --- a/core/meta/inc/TProtoClass.h +++ b/core/meta/inc/TProtoClass.h @@ -20,11 +20,7 @@ class TClass; class TList; class TRealData; -#ifdef R__LESS_INCLUDES class TDataMember; -#else -#include "TDataMember.h" -#endif ////////////////////////////////////////////////////////////////////////// // // diff --git a/core/meta/inc/TSchemaRuleSet.h b/core/meta/inc/TSchemaRuleSet.h index a7257f2e65c27..d3cd84f8ddbdc 100644 --- a/core/meta/inc/TSchemaRuleSet.h +++ b/core/meta/inc/TSchemaRuleSet.h @@ -9,12 +9,7 @@ #include "TClassRef.h" #include -#ifdef R__LESS_INCLUDES class TObjArray; -#else -#include "TObjArray.h" -#endif - namespace ROOT { diff --git a/core/thread/inc/TThread.h b/core/thread/inc/TThread.h index df763bd6c27ef..d8d334035770e 100644 --- a/core/thread/inc/TThread.h +++ b/core/thread/inc/TThread.h @@ -28,12 +28,7 @@ #include "TTimer.h" #include -#ifdef R__LESS_INCLUDES class TCondition; -#else -#include "TCondition.h" -#endif - class TMutex; class TThreadImp; diff --git a/geom/geom/inc/TGeoCache.h b/geom/geom/inc/TGeoCache.h index b14153aa690ae..a99c818562168 100644 --- a/geom/geom/inc/TGeoCache.h +++ b/geom/geom/inc/TGeoCache.h @@ -15,13 +15,8 @@ #include "TGeoNode.h" -#ifdef R__LESS_INCLUDES -struct TGeoStateInfo; -#else -#include "TGeoStateInfo.h" -#endif - // forward declarations +struct TGeoStateInfo; class TGeoManager; class TGeoHMatrix; diff --git a/geom/geom/inc/TGeoMaterial.h b/geom/geom/inc/TGeoMaterial.h index d0fa0d88389c0..8b1559275da19 100644 --- a/geom/geom/inc/TGeoMaterial.h +++ b/geom/geom/inc/TGeoMaterial.h @@ -16,14 +16,9 @@ #include #include -#ifdef R__LESS_INCLUDES +// forward declarations class TGeoElement; class TGeoElementTable; -#else -#include "TGeoElement.h" -#endif - -// forward declarations class TGeoExtension; class TGDMLMatrix; diff --git a/graf2d/gpad/inc/TControlBar.h b/graf2d/gpad/inc/TControlBar.h index da4da8fdef4c5..6797d270c55d7 100644 --- a/graf2d/gpad/inc/TControlBar.h +++ b/graf2d/gpad/inc/TControlBar.h @@ -14,12 +14,8 @@ #include "TControlBarButton.h" -#ifdef R__LESS_INCLUDES class TObjArray; class TControlBarImp; -#else -#include "TControlBarImp.h" -#endif class TList; diff --git a/graf2d/gpad/inc/TPaveClass.h b/graf2d/gpad/inc/TPaveClass.h index bdbe7a2e58104..2df50c7692580 100644 --- a/graf2d/gpad/inc/TPaveClass.h +++ b/graf2d/gpad/inc/TPaveClass.h @@ -14,11 +14,7 @@ #include "TPaveLabel.h" -#ifdef R__LESS_INCLUDES class TClassTree; -#else -#include "TClassTree.h" -#endif class TPaveClass : public TPaveLabel { diff --git a/graf2d/graf/inc/TGraphPolar.h b/graf2d/graf/inc/TGraphPolar.h index f920bbe97e4e2..d7cbdd6fb3938 100644 --- a/graf2d/graf/inc/TGraphPolar.h +++ b/graf2d/graf/inc/TGraphPolar.h @@ -14,11 +14,7 @@ #include "TGraphErrors.h" -#ifdef R__LESS_INCLUDES class TGraphPolargram; -#else -#include "TGraphPolargram.h" -#endif class TGraphPolar : public TGraphErrors { diff --git a/hist/hist/inc/THStack.h b/hist/hist/inc/THStack.h index 70f59bd3fea25..2f0760fb21db2 100644 --- a/hist/hist/inc/THStack.h +++ b/hist/hist/inc/THStack.h @@ -24,13 +24,9 @@ #include "TNamed.h" #include "TObjArray.h" -#ifdef R__LESS_INCLUDES class TH1; class TList; class TAxis; -#else -#include "TH1.h" -#endif #include diff --git a/hist/hist/inc/TSpline.h b/hist/hist/inc/TSpline.h index a90e9c5b3ca19..6c3b92829db9f 100644 --- a/hist/hist/inc/TSpline.h +++ b/hist/hist/inc/TSpline.h @@ -12,14 +12,10 @@ #ifndef ROOT_TSpline #define ROOT_TSpline -#ifdef R__LESS_INCLUDES #include "TNamed.h" #include "TAttLine.h" #include "TAttFill.h" #include "TAttMarker.h" -#else -#include "TGraph.h" -#endif class TH1; class TH1F; diff --git a/io/io/inc/TFile.h b/io/io/inc/TFile.h index ee87f2bb96bb4..7caff270cd573 100644 --- a/io/io/inc/TFile.h +++ b/io/io/inc/TFile.h @@ -31,11 +31,6 @@ #include "ROOT/RConcurrentHashColl.hxx" #include -// Not a part of TFile interface; provide a forward declaration instead of #include. -// #ifndef R__LESS_INCLUDES -// #include "TMap.h" -// #endif - #ifdef R__USE_IMT #include #endif diff --git a/io/io/inc/TFilePrefetch.h b/io/io/inc/TFilePrefetch.h index 0fecbb3700d24..116b7ad00d63f 100644 --- a/io/io/inc/TFilePrefetch.h +++ b/io/io/inc/TFilePrefetch.h @@ -22,13 +22,8 @@ #include #include -#ifdef R__LESS_INCLUDES class TSemaphore; class TFPBlock; -#else -#include "TSemaphore.h" -#include "TFPBlock.h" -#endif class TFilePrefetch : public TObject { diff --git a/io/io/inc/TKey.h b/io/io/inc/TKey.h index 4a454f18ff39e..50db266126284 100644 --- a/io/io/inc/TKey.h +++ b/io/io/inc/TKey.h @@ -15,13 +15,9 @@ #include "TNamed.h" #include "TDatime.h" #include "TClass.h" -#ifdef R__LESS_INCLUDES -class TBuffer; -#else -#include "TBuffer.h" -#endif class TBrowser; +class TBuffer; class TDirectory; class TFile; diff --git a/tree/tree/inc/ROOT/TIOFeatures.hxx b/tree/tree/inc/ROOT/TIOFeatures.hxx index 11e0c54d5d6a6..3c95c9928727b 100644 --- a/tree/tree/inc/ROOT/TIOFeatures.hxx +++ b/tree/tree/inc/ROOT/TIOFeatures.hxx @@ -17,16 +17,6 @@ class TBasket; class TBranch; class TTree; -// keep it here to have a note that was removed -// #ifndef R__LESS_INCLUDES -// #include "TBasket.h" -// #include -// #include -// #include -// #include -// #include // is_same, enable_if -// #endif - namespace ROOT { diff --git a/tree/tree/inc/TBranchRef.h b/tree/tree/inc/TBranchRef.h index f0f9eb83a3cf9..15b2352ea6c68 100644 --- a/tree/tree/inc/TBranchRef.h +++ b/tree/tree/inc/TBranchRef.h @@ -23,12 +23,7 @@ #include "TBranch.h" -#ifdef R__LESS_INCLUDES class TRefTable; -#else -#include "TRefTable.h" -#endif - class TTree; class TBranchRef : public TBranch { diff --git a/tree/tree/inc/TLeaf.h b/tree/tree/inc/TLeaf.h index 00692d43a8a46..b2fa4d3ac4067 100644 --- a/tree/tree/inc/TLeaf.h +++ b/tree/tree/inc/TLeaf.h @@ -45,12 +45,7 @@ #include -#ifdef R__LESS_INCLUDES class TBranch; -#else -#include "TBranch.h" -#endif - class TClonesArray; class TBrowser; diff --git a/tree/tree/inc/TTree.h b/tree/tree/inc/TTree.h index d6fce55392fc7..38fac5d3af7d9 100644 --- a/tree/tree/inc/TTree.h +++ b/tree/tree/inc/TTree.h @@ -39,20 +39,13 @@ #include "TObjArray.h" #include "TVirtualTreePlayer.h" -#ifdef R__LESS_INCLUDES -class TBranch; -class TList; -#else -#include "TBranch.h" -// #include "TBuffer.h" -#include "TList.h" -#endif - #include #include #include #include +class TBranch; +class TList; class TBuffer; class TBrowser; class TFile;