X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/172d3acb55b52a5ed15fc7c78a38825978bbc5c8..ce1a1ff40afbe6d8d2c9ec2b422ec48364171935:/docs/html/standard.htm 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 Vadim Zeitlin

This guide is intended for people who are (or intending to start) writing code -for wxWindows class library. +for wxWindows class library.

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.

Acknowledgements: This guide is partly based on +HREF="http://www.mozilla.org/hacking/portable-cpp.html" target=_top> C++ portability guide by David Williams.

@@ -50,6 +50,7 @@ C++ portability guide by David Williams.

  • Don't use STL
  • Don't declare variables inside for()
  • Don't use nested classes
  • +
  • Use ternary operator ?: carefully

  • General recommendations
  • @@ -332,6 +333,25 @@ you can try the following:

    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). + +

  • Use ternary operator ?: carefully
  • + The ternary operator ?: 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. +

    Workaround: use if/else instead. +

    +    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;
    +