Difference between revisions of "Coding Conventions"

Jump to navigation Jump to search
394 bytes added ,  18:18, 19 April 2010
(→‎Language features: Mention that C++ global objects are bad)
Line 6: Line 6:
== Language features ==
== Language features ==
ScummVM is written in a subset of C++. Due to limitations of the C++ run-times on various platforms, the following features cannot be used:
ScummVM is written in a subset of C++. Due to limitations of the C++ run-times on various platforms, the following features cannot be used:
* C++ exceptions (throw/catch)
* C++ exceptions (throw/catch): Not all C++ compilers support these correctly (esp. on embedded systems), and exception support incurs a noticeable overhead in binary size.
* C++ RTTI (run-time type information, as in dynamic_cast<>)
* C++ RTTI (run-time type information, as in dynamic_cast<>): This incurs a severe overhead in binary size and memory usage, as every C++ object is enlarged by RTTI information
* global C++ objects (their constructors / destructors will not be called on certain targets)
* Global C++ objects: Their constructors / destructors will not be called on certain targets, causing all kinds of bad problems and requiring ugly workarounds. (The GCC option -Wglobal-constructors helps finding code doing this.)


Furthermore, the standard C++ library is a big no-no. Besides usually heavily relying on the above mentioned features, it also sucks up rather more resources than we would like to, so we have our own replacements for various container classes etc.
Furthermore, the standard C++ library is a big no-no. Besides usually heavily relying on the above mentioned features, it also sucks up rather more resources than we would like to, so we have our own replacements for various container classes etc.
1,079

edits

Navigation menu