X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/172d3acb55b52a5ed15fc7c78a38825978bbc5c8..ce1a1ff40afbe6d8d2c9ec2b422ec48364171935:/docs/html/standard.htm?ds=sidebyside diff --git a/docs/html/standard.htm b/docs/html/standard.htm index 61d507667e..fa5270c36e 100644 --- a/docs/html/standard.htm +++ b/docs/html/standard.htm @@ -24,7 +24,7 @@ wxWindows Programmer Style Guide by <A HREF=mailto:zeitlin@dptmaths.ens-cachan.fr>Vadim Zeitlin</A><P> This guide is intended for people who are (or intending to start) writing code -for <A HREF="http://web.ukonline.co.uk/julian.smart/wxwin/" target=_top>wxWindows</A> class library. +for <A HREF="http://www.wxwindows.org" target=_top>wxWindows</A> class library. <P> The guide is separated into two parts: the first one addresses the general @@ -35,7 +35,7 @@ its goal it to make wxWindows as uniform as possible without imposing too many restrictions on the programmer. <P> Acknowledgements: This guide is partly based on <A -HREF=http://www.mozilla.org/docs/tplist/catBuild/portable-cpp.html target=_top> +HREF="http://www.mozilla.org/hacking/portable-cpp.html" target=_top> C++ portability guide</A> by David Williams. <P> @@ -50,6 +50,7 @@ C++ portability guide</A> by David Williams. <LI><A HREF="#no_stl">Don't use STL</A></LI> <LI><A HREF="#no_fordecl">Don't declare variables inside <TT>for()</TT></A></LI> <LI><A HREF="#no_nestedclasses">Don't use nested classes</A></LI> + <LI><A HREF="#no_ternarywithobjects">Use ternary operator ?: carefully</A></LI> </OL> <BR> <LI>General recommendations</LI> @@ -332,6 +333,25 @@ you can try the following: <P>A nice side effect is that you don't need to recompile all the files including the header if you change the PrivateLibClass declaration (it's an example of a more general interface/implementation separation idea). + + <P><LI><A NAME="no_ternarywithobjects"></A><B>Use ternary operator ?: carefully</B></LI><P> + The ternary operator <TT>?:</TT> shouldn't be used with objects (i.e. if any +of its operands are objects) because some compilers (notable Borland C++) fail +to compile such code. +<P><U>Workaround</U>: use <TT>if/else</TT> instead. +<PRE> + wxString s1, s2; + + // Borland C++ won't compile the line below + wxString s = s1.Len() < s2.Len() ? s1 : s2; + + // but any C++ compiler will compile this + wxString s; + if ( s1.Len() < s2.Len() ) + s = s1; + else + s = s2; +</PRE> </OL> <BR>