mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
docs(CONTRIBUTING): add a guideline to not use dynamic casts/RTTI
And enforce it during compilation.
This commit is contained in:
parent
8b0f3912b1
commit
abaa41eaee
@ -310,6 +310,20 @@ QObject notToMentionThatWeUseCamelCase;
|
|||||||
|
|
||||||
E.g. https://github.com/qTox/qTox/blob/master/src/misc/flowlayout.cpp
|
E.g. https://github.com/qTox/qTox/blob/master/src/misc/flowlayout.cpp
|
||||||
|
|
||||||
|
|
||||||
|
## Dynamic casts / RTTI
|
||||||
|
|
||||||
|
qTox is compiled without support for RTTI, as such PRs making use of
|
||||||
|
`dynamic_cast()` will fail to compile and may be rejected on this basis. For
|
||||||
|
manipulating Qt-based objects, use `qobject_cast()` instead.
|
||||||
|
|
||||||
|
Compiling qTox without RTTI support gives up to 5-6% size reductions on
|
||||||
|
compiled binary files. The usage of `dynamic_cast()` can also be completely
|
||||||
|
mitigated when dealing with Qt objects through use of `qobject_cast()` which
|
||||||
|
behaves very much like C++'s `dynamic_cast()` but without the RTTI overhead.
|
||||||
|
|
||||||
|
Enforced with `-fno-rtti`.
|
||||||
|
|
||||||
## Documentaion
|
## Documentaion
|
||||||
|
|
||||||
If you added a new function, also add a doxygen comment before the
|
If you added a new function, also add a doxygen comment before the
|
||||||
|
2
qtox.pro
2
qtox.pro
@ -40,7 +40,7 @@ FORMS += \
|
|||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
|
|
||||||
QMAKE_CXXFLAGS += -fno-exceptions
|
QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti
|
||||||
QMAKE_RESOURCE_FLAGS += -compress 9 -threshold 0
|
QMAKE_RESOURCE_FLAGS += -compress 9 -threshold 0
|
||||||
|
|
||||||
# Rules for creating/updating {ts|qm}-files
|
# Rules for creating/updating {ts|qm}-files
|
||||||
|
Loading…
x
Reference in New Issue
Block a user