C++ style guide: Difference between revisions

Jump to navigation Jump to search
288 bytes removed ,  20 June 2016
→‎Other C++ features: C++11 is now allowed and C++14 is the new not allowed
(fix link to m-file style guide)
(→‎Other C++ features: C++11 is now allowed and C++14 is the new not allowed)
Line 43: Line 43:
=== C++11 ===
=== C++11 ===


Do not use C++11 features.  Octave is widely used in very old systems and we
C++11 features are generally allowed. Check if the feature you want to
use has been already used.  If not, ask on the mailing list.
 
=== C++14 ===
 
Do not use C++14 features.  Octave is widely used in very old systems and we
want them to be able to use up to date versions of Octave.  Building a recent
want them to be able to use up to date versions of Octave.  Building a recent
compiler in such systems is not a trivial task so the limitation must happen
compiler in such systems is not a trivial task so the limitation must happen
in Octave.  See [https://lists.gnu.org/archive/html/octave-maintainers/2014-11/msg00069.html A case for C++11] in the maintainers mailing list.
in Octave.
 
As of Octave 4.2, Octave's configure will enable C++11 if the compiler
supports it.  Still, do not use C++11 features.


An exception: code that requires C++11 feature must also implement an
An exception: code that requires C++14 feature must also implement an
alternative code in the absence of said feature.  In such case, use a
alternative code in the absence of said feature.  In such case, use a
configure check.  This increases maintenance a lot, must be used sparsely,
configure check.  This increases maintenance a lot, must be used sparsely,
and requires approval from other maintainers.
and requires approval from other maintainers.


  #if HAVE_THIS_C11_FEATURE
  #if HAVE_THIS_C14_FEATURE
   // code that really needs it
   // code that really needs it
  #else
  #else
   // alternative code in its absence
   // alternative code in its absence
  #endif
  #endif
This decision may be revisited in the future once cross-compiling becomes
more mature.
=== C++14 ===
Do not use C++14 features.  Same reason as why C++11 features are not allowed.

Navigation menu