Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.9
-
None
-
185cba6e9 (dev), 11f94598d (6.9)
Description
qdebug.h includes a ton of headers from Qt and the C++ standard library. That cost is basically imposed on anything that includes qdebug.h. Although Qt includes a lot of the standard library on its own (just QList/QString/QVariant alone will end up including <functional>, <algorithm>, <string>, <string_view>, <memory>, <type_traits>, <vector>, <variant>...), qdebug.h goes maybe a bit overboard:
#include <array> #include <chrono> #include <list> #include <map> #include <memory> #include <optional> #include <set> #include <string> #include <string_view> #include <set> #include <tuple> #include <QtCore/q20type_traits.h> #include <unordered_map> #include <unordered_set> #include <utility> #include <unordered_map> #include <unordered_set> #include <vector>
We don't have a good solution for this, such as isolate the streaming operators of C++ types in another header. (A very similar issue exists with qhash.h and the hashers for standard library types.)
However, we have some public headers that include qdebug.h. That means that now including those headers will pull in half of the STL. The heaviest offender is qvariant.h, but a quick search reveals more:
corelib/kernel/qcoreapplication.h 19:#include <QtCore/qdebug.h> network/socket/qlocalsocket.h 12:#include <QtCore/qdebug.h> network/socket/qabstractsocket.h 17:#include <QtCore/qdebug.h> gui/math3d/qgenericmatrix.h 9:#include <QtCore/qdebug.h> corelib/kernel/qvariant.h 12:#include <QtCore/qdebug.h>
Should we try and avoid including qdebug.h from any public header?