item about constants naming added

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3743 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-09-21 11:39:52 +00:00
parent 556921dc4e
commit 172d3acb55

View File

@@ -108,6 +108,7 @@ C++ portability guide</A> by David Williams.
<LI><A HREF="#wxdllexport">Use WXDLLEXPORT with all classes/functions in <LI><A HREF="#wxdllexport">Use WXDLLEXPORT with all classes/functions in
wxMSW/common code</A></LI> wxMSW/common code</A></LI>
<LI><A HREF="#set_get">Use Set/Get prefixes for accessors</A></LI> <LI><A HREF="#set_get">Use Set/Get prefixes for accessors</A></LI>
<LI><A HREF="#constants">wxNAMING_CONSTANTS</A></LI>
</OL> </OL>
<BR> <BR>
@@ -423,7 +424,7 @@ sizes are different. A small table illustrates it quite well:
Although close to the heart of many C programmers (I plead guilty), code like Although close to the heart of many C programmers (I plead guilty), code like
classical <TT>if ( (c = getchar()) != EOF )</TT> is bad because it prevents you classical <TT>if ( (c = getchar()) != EOF )</TT> is bad because it prevents you
from enabling "assignment in conditional expression" warning (see also from enabling "assignment in conditional expression" warning (see also
<A HREF="#no_warnings">above</A>) warning which is helpful to detect common <A HREF="#no_warnings">above</A>) which is helpful to detect common
mistypes like <TT>if ( x = 2 )</TT> instead of <TT>if ( x == 2 )</TT>. mistypes like <TT>if ( x = 2 )</TT> instead of <TT>if ( x == 2 )</TT>.
<P><LI><A NAME="no_comment_code"></A><B>Use <TT>#if 0</TT> rather than comments to temporarily <P><LI><A NAME="no_comment_code"></A><B>Use <TT>#if 0</TT> rather than comments to temporarily
@@ -742,6 +743,25 @@ case you should put them inside <TT>common/cmndata.cpp</TT> file.
There is a convention in wxWindows to prefix the accessors (i.e. any simple, in There is a convention in wxWindows to prefix the accessors (i.e. any simple, in
general, inline function which does nothing else except changing or returning general, inline function which does nothing else except changing or returning
the value of a member variable) with either <TT>Set</TT> or <TT>Get</TT>. the value of a member variable) with either <TT>Set</TT> or <TT>Get</TT>.
<P><LI><A NAME="constants"></LI><B>wxNAMING_CONSTANTS</B><P>
The constants in wxWindows code should be defined using <TT>enum</TT> C++
keyword (and not with <TT>#define</TT> or <TT>static const int</TT>). They
should be declared in the global scope (and not inside class declaration) and
their names should start with a <TT>wx</TT> prefix. Finally, the constants
should be in all capital letters (except the first 2) to make it easier to
distinguish them from the variables with underscores separating the words.
<P>For example, file-related constants should be declared like this:
<pre>
enum
{
wxFILEOPEN_READ,
wxFILEOPEN_WRITE,
wxFILEOPEN_READWRITE
};
</pre>
</OL> </OL>
<P><LI>Miscellaneous</LI><P> <P><LI>Miscellaneous</LI><P>
@@ -764,7 +784,7 @@ stubs for not (yet) implemented functions which silently return incorrect
values - otherwise, a person using a not implemented function has no idea that values - otherwise, a person using a not implemented function has no idea that
it is, in fact, not implemented. it is, in fact, not implemented.
<P>As all debugging macros only do something useful if the symbol <P>As all debugging macros only do something useful if the symbol
<TT>__DEBUG__</TT> is defined, you should compile your programs in debug mode to profit <TT>__WXDEBUG__</TT> is defined, you should compile your programs in debug mode to profit
from them. from them.
</OL> </OL>
</UL> </UL>