Loading docs/code-quality/coding-style/using_cxx_in_firefox_code.rst +44 −38 Original line number Diff line number Diff line Loading @@ -300,42 +300,48 @@ Sources Notes ~~~~~ rvalue references: Implicit move method generation cannot be used. rvalue references Implicit move method generation cannot be used. Attributes: Several common attributes are defined in Attributes Several common attributes are defined in `mozilla/Attributes.h <https://searchfox.org/mozilla-central/source/mfbt/Attributes.h>`__ or nscore.h. Alignment: Some alignment utilities are defined in `mozilla/Alignment.h <https://searchfox.org/mozilla-central/source/mfbt/Alignment.h>`__. /!\\ MOZ_ALIGNOF and alignof don't have the same semantics. Be careful of what you expect from them. Alignment Some alignment utilities are defined in `mozilla/Alignment.h <https://searchfox.org/mozilla-central/source/mfbt/Alignment.h>`__. ``[[deprecated]]``: If we have deprecated code, we should be removing it rather than marking it as such. Marking things as ``[[deprecated]]`` also means the compiler will warn if you use the deprecated API, which turns into a fatal error in our automation builds, which is not helpful. .. caution:: ``MOZ_ALIGNOF`` and ``alignof`` don't have the same semantics. Be careful of what you expect from them. Sized deallocation: Our compilers all support this (custom flags are required for GCC and Clang), but turning it on breaks some classes' ``operator new`` methods, and `some work <https://bugzilla.mozilla.org/show_bug.cgi?id=1250998>`__ would need to be done to make it an efficiency win with our custom memory allocator. ``[[deprecated]]`` If we have deprecated code, we should be removing it rather than marking it as such. Marking things as ``[[deprecated]]`` also means the compiler will warn if you use the deprecated API, which turns into a fatal error in our automation builds, which is not helpful. Aligned allocation/deallocation: Our custom memory allocator doesn't have support for these functions. Sized deallocation Our compilers all support this (custom flags are required for GCC and Clang), but turning it on breaks some classes' ``operator new`` methods, and `some work <https://bugzilla.mozilla.org/show_bug.cgi?id=1250998>`__ would need to be done to make it an efficiency win with our custom memory allocator. Thread locals: ``thread_local`` is not supported on Android. Aligned allocation/deallocation Our custom memory allocator doesn't have support for these functions. Designated initializers: Despite their late addition to C++ (and lack of *official* support by compilers until relatively recently), `C++20's designated initializers Thread locals ``thread_local`` is not supported on Android. Designated initializers Despite their late addition to C++ (and lack of *official* support by compilers until relatively recently), `C++20's designated initializers <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0329r4.pdf>`__ are merely a subset of `a feature originally introduced in C99 <https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html>`__ -- and this subset has been accepted without comment in C++ code since at least GCC 4.7 and Clang 3.0. <https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html>`__ -- and this subset has been accepted without comment in C++ code since at least GCC 4.7 and Clang 3.0. C++ and Mozilla standard libraries Loading Loading
docs/code-quality/coding-style/using_cxx_in_firefox_code.rst +44 −38 Original line number Diff line number Diff line Loading @@ -300,42 +300,48 @@ Sources Notes ~~~~~ rvalue references: Implicit move method generation cannot be used. rvalue references Implicit move method generation cannot be used. Attributes: Several common attributes are defined in Attributes Several common attributes are defined in `mozilla/Attributes.h <https://searchfox.org/mozilla-central/source/mfbt/Attributes.h>`__ or nscore.h. Alignment: Some alignment utilities are defined in `mozilla/Alignment.h <https://searchfox.org/mozilla-central/source/mfbt/Alignment.h>`__. /!\\ MOZ_ALIGNOF and alignof don't have the same semantics. Be careful of what you expect from them. Alignment Some alignment utilities are defined in `mozilla/Alignment.h <https://searchfox.org/mozilla-central/source/mfbt/Alignment.h>`__. ``[[deprecated]]``: If we have deprecated code, we should be removing it rather than marking it as such. Marking things as ``[[deprecated]]`` also means the compiler will warn if you use the deprecated API, which turns into a fatal error in our automation builds, which is not helpful. .. caution:: ``MOZ_ALIGNOF`` and ``alignof`` don't have the same semantics. Be careful of what you expect from them. Sized deallocation: Our compilers all support this (custom flags are required for GCC and Clang), but turning it on breaks some classes' ``operator new`` methods, and `some work <https://bugzilla.mozilla.org/show_bug.cgi?id=1250998>`__ would need to be done to make it an efficiency win with our custom memory allocator. ``[[deprecated]]`` If we have deprecated code, we should be removing it rather than marking it as such. Marking things as ``[[deprecated]]`` also means the compiler will warn if you use the deprecated API, which turns into a fatal error in our automation builds, which is not helpful. Aligned allocation/deallocation: Our custom memory allocator doesn't have support for these functions. Sized deallocation Our compilers all support this (custom flags are required for GCC and Clang), but turning it on breaks some classes' ``operator new`` methods, and `some work <https://bugzilla.mozilla.org/show_bug.cgi?id=1250998>`__ would need to be done to make it an efficiency win with our custom memory allocator. Thread locals: ``thread_local`` is not supported on Android. Aligned allocation/deallocation Our custom memory allocator doesn't have support for these functions. Designated initializers: Despite their late addition to C++ (and lack of *official* support by compilers until relatively recently), `C++20's designated initializers Thread locals ``thread_local`` is not supported on Android. Designated initializers Despite their late addition to C++ (and lack of *official* support by compilers until relatively recently), `C++20's designated initializers <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0329r4.pdf>`__ are merely a subset of `a feature originally introduced in C99 <https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html>`__ -- and this subset has been accepted without comment in C++ code since at least GCC 4.7 and Clang 3.0. <https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html>`__ -- and this subset has been accepted without comment in C++ code since at least GCC 4.7 and Clang 3.0. C++ and Mozilla standard libraries Loading