Difference between revisions of "Coding Conventions"

Jump to navigation Jump to search
906 bytes added ,  09:29, 11 April 2011
(Add link to CFC)
Line 65: Line 65:
</syntax>
</syntax>
is ''not'' sufficient.
is ''not'' sufficient.
Therefore, '''use of non-const static globals inside function bodies is strictly forbidden''', as there is no way to reset them from code outside of that function.
In addition, global variables are strongly discouraged; if they are to be used, then they ''must'' be accompanied by a comment that explains why this static variable is necessary, and why it cannot be replaced by something else, like typically a member variable of a suitable class / object. The comment should also indicate where the variable is (re)set when the engine launches. If no such comment is present, a generic comment of the following form shall be added to the variable declaration:
<syntax type="C++">
  // FIXME: non-const global var
</syntax>
As a minor exception, if an existing engine uses many globals (due to not (yet) being objectified), it is permissible to use a single comment to document multiple globals at once.
1,079

edits

Navigation menu