Changes between Version 8 and Version 9 of CppSupport


Ignore:
Timestamp:
Dec 6, 2020, 3:43:13 PM (3 years ago)
Author:
wraitii
Comment:

C++17 / Post SM78 update

Legend:

Unmodified
Added
Removed
Modified
  • CppSupport

    v8 v9  
    1 
    2 This page will attempt to describe features of modern C++ standards (C++11, C++14, etc.) supported by the game. For information on building the game, see BuildInstructions.
     1This page will attempt to describe features of modern C++ standards (C++17, etc.) supported by the game. For information on building the game, see BuildInstructions.
    32
    43= Supported Compilers =
     40 A.D. is a cross platform game written primarily in C++ and JavaScript, and as such it has to support multiple compilers with different implemented features. Here are the currently supported compilers for the game:
    55
    6 0 A.D. is a cross platform game written primarily in C++ and JavaScript, and as such it has to support multiple compilers with different implemented features. Here are the currently supported compilers for the game:
    7  * GCC 4.8.1 or newer
    8  * Clang 3.4 or newer
    9   * Shipped with Xcode 5.1 ([https://gist.github.com/yamaya/2924292 according to the documentation]) on OS X
    10   * '''Note:''' older versions may work, but this isn't guaranteed
    11  * Visual Studio 2015
     6 * GCC 7 or newer
     7 * Clang 6 or newer
     8   * Shipped with Xcode 9.3 on OS X, which is 10.13+ (which also has 10.1)
     9 * Visual Studio 2017
    1210
    13 The following tables summarize C++11 support for the above compilers. Features available (Y) in all supported compilers are marked green and believed safe to use. Features not available (N) in all supported compilers are marked red and generally should not be used in 0 A.D. In a few cases there is partial support (P), these rows are yellow.
     11In general, all features up to and including C++17 are usable.
    1412
    15 Code examples are given for many features as the formal names can be unclear.
     13See the following links for details: [https://docs.microsoft.com/fr-fr/cpp/overview/visual-cpp-language-conformance?view=msvc-160 MSVC] / [https://www.google.com/search?client=safari&rls=en&q=clang+c%2B%2B+support&ie=UTF-8&oe=UTF-8 Clang] / [https://gcc.gnu.org/projects/cxx-status.html GCC]
    1614
    17 = C++11 Core Language Features =
     15Known exceptions are the above features reported by Microsoft:
    1816
    19 ||= Feature =||= Example =||= GCC 4.8.1 =||= Clang 3.4 =||= VS 2015 =||= '''0 A.D. Support''' =||= Notes =||
    20 {{{#!tr style="background: LightGreen"
    21 ||Emplacement||`emplace`, `emplace_back`||  Y  ||  Y  ||  Y  ||  Y  || ||
    22 }}}
    23 {{{#!tr style="background: LightGreen"
    24 ||Rvalue references||`type_t &&`||  Y  ||  Y  ||  Y  ||  Y  || ||
    25 }}}
    26 {{{#!tr style="background: Pink"
    27 ||Rvalue references for *this||`void RValueFunc() &&;`||  Y  ||  Y  ||  N  ||  N  || [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1821.htm N1821] ||
    28 }}}
    29 {{{#!tr style="background: LightGreen"
    30 ||Initialization of class objects by rvalues|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    31 }}}
    32 {{{#!tr style="background: LightGreen"
    33 ||Non-static data member initializers||`class Foo{ public: int bar=7; };`||  Y  ||  Y  ||  Y  ||  Y  || ||
    34 }}}
    35 {{{#!tr style="background: LightGreen"
    36 ||Variadic templates||`template<typename T, typename... Args>`||  Y  ||  Y  ||  Y  ||  Y  || ||
    37 }}}
    38 {{{#!tr style="background: LightGreen"
    39 ||Extending variadic template template parameters|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    40 }}}
    41 {{{#!tr style="background: LightGreen"
    42 ||Initializer lists||`vector<int> v = { 1, 2, 3, 4, 5, 6 };`||  Y  ||  Y  ||  Y  ||  Y  || ||
    43 }}}
    44 {{{#!tr style="background: LightGreen"
    45 ||Static assertions||`static_assert(expression,message);`||  Y  ||  Y  ||  Y  ||  Y  || ||
    46 }}}
    47 {{{#!tr style="background: LightGreen"
    48 ||auto-typed variables|| `for (auto p = v.begin(); p!=v.end(); ++p)` ||  Y  ||  Y  ||  Y  ||  Y  || ||
    49 }}}
    50 {{{#!tr style="background: LightGreen"
    51 ||Multi-declarator auto||`for (auto p = v.begin(), e=v.end(); p!=e; ++p)`||  Y  ||  Y  ||  Y  ||  Y  || ||
    52 }}}
    53 {{{#!tr style="background: LightGreen"
    54 ||Removal of auto as a storage-class specifier||~~`auto int r;`~~||  Y  ||  Y  ||  Y  ||  Y  || ||
    55 }}}
    56 {{{#!tr style="background: LightGreen"
    57 ||New function declarator syntax|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    58 }}}
    59 {{{#!tr style="background: LightGreen"
    60 ||New wording for C++0x lambdas|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    61 }}}
    62 {{{#!tr style="background: LightGreen"
    63 ||Declared type of an expression||`typedef decltype(a[0]*b[0]) Tmp;`||  Y  ||  Y  ||  Y  ||  Y  || ||
    64 }}}
    65 {{{#!tr style="background: LightGreen"
    66 ||Incomplete return types|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    67 }}}
    68 {{{#!tr style="background: LightGreen"
    69 ||Right angle brackets||`list<vector<string>> lvs;`||  Y  ||  Y  ||  Y  ||  Y  || ||
    70 }}}
    71 {{{#!tr style="background: LightGreen"
    72 ||Default template arguments for function templates|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    73 }}}
    74 {{{#!tr style="background: LightYellow"
    75 ||Solving the SFINAE problem for expressions|| ||  Y  ||  Y  ||  P  ||  N  || ||
    76 }}}
    77 {{{#!tr style="background: LightGreen"
    78 ||Template aliases||`template<class T> using Vec = vector<T,My_alloc<T>>;`||  Y  ||  Y  ||  Y  ||  Y  || ||
    79 }}}
    80 {{{#!tr style="background: LightGreen"
    81 ||Extern templates||`extern template class Foo<int>;`||  Y  ||  Y  ||  Y  ||  Y  || ||
    82 }}}
    83 {{{#!tr style="background: LightGreen"
    84 ||Null pointer constant||`char* p = nullptr;`||  Y  ||  Y  ||  Y  ||  Y  || ||
    85 }}}
    86 {{{#!tr style="background: LightGreen"
    87 ||Strongly-typed enums||`enum foo : int {};`||  Y  ||  Y  ||  Y  ||  Y  || ||
    88 }}}
    89 {{{#!tr style="background: LightGreen"
    90 ||Forward declarations for enums||`enum class Foo : char;`||  Y  ||  Y  ||  Y  ||  Y  || ||
    91 }}}
    92 {{{#!tr style="background: LightGreen"
    93 ||Generalized attributes||`[[attributes]]`||  Y  ||  Y  ||  Y  ||  Y  || ||
    94 }}}
    95 {{{#!tr style="background: LightYellow"
    96 ||Generalized constant expressions||`constexpr int a = b.x;`||  Y  ||  Y  ||  P  ||  N  || Issues discovered in VS 2015 ||
    97 }}}
    98 {{{#!tr style="background: LightGreen"
    99 ||Alignment support||`alignas(16) char[100];`||  Y  ||  Y  ||  Y  ||  Y  ||  ||
    100 }}}
    101 {{{#!tr style="background: LightGreen"
    102 ||Delegating constructors|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    103 }}}
    104 {{{#!tr style="background: LightGreen"
    105 ||Inheriting constructors|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    106 }}}
    107 {{{#!tr style="background: LightGreen"
    108 ||Explicit conversion operators||`explicit operator bool()`||  Y  ||  Y  ||  Y  ||  Y  || ||
    109 }}}
    110 {{{#!tr style="background: LightGreen"
    111 ||New character types||`char16_t` / `char32_t`||  Y  ||  Y  ||  Y  ||  Y  || ||
    112 }}}
    113 {{{#!tr style="background: LightGreen"
    114 ||Unicode string literals||`u"string"`||  Y  ||  Y  ||  Y  ||  Y  || ||
    115 }}}
    116 {{{#!tr style="background: LightGreen"
    117 ||Raw string literals||` r"\string!\";`||  Y  ||  Y  ||  Y  ||  Y  || ||
    118 }}}
    119 {{{#!tr style="background: LightGreen"
    120 ||Universal character name literals|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    121 }}}
    122 {{{#!tr style="background: LightGreen"
    123 ||User-defined literals / extensible literals||`std::string operator""s (const char* p, size_t n)`||  Y  ||  Y  ||  Y  ||  Y  || ||
    124 }}}
    125 {{{#!tr style="background: LightGreen"
    126 ||Standard Layout Types||`struct Foo { int a; Foo(int aa) : a(aa) { } };`||  Y  ||  Y  ||  Y  ||  Y  || ||
    127 }}}
    128 {{{#!tr style="background: LightGreen"
    129 ||Defaulted and deleted functions||`X& operator=(const X&) = delete;`||  Y  ||  Y  ||  Y  ||  Y  || ||
    130 }}}
    131 {{{#!tr style="background: LightGreen"
    132 ||Extended friend declarations|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    133 }}}
    134 {{{#!tr style="background: LightGreen"
    135 ||Extending sizeof|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    136 }}}
    137 {{{#!tr style="background: LightGreen"
    138 ||Inline namespaces|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    139 }}}
    140 {{{#!tr style="background: LightGreen"
    141 ||Unrestricted unions|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    142 }}}
    143 {{{#!tr style="background: LightGreen"
    144 ||Local and unnamed types as template arguments|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    145 }}}
    146 {{{#!tr style="background: LightGreen"
    147 ||Range-based for||`for (auto x : vec)`||  Y  ||  Y  ||  Y  ||  Y  || ||
    148 }}}
    149 {{{#!tr style="background: LightGreen"
    150 ||Explicit virtual overrides||`void f() override;`||  Y  ||  Y  ||  Y  ||  Y  || ||
    151 }}}
    152 {{{#!tr style="background: Pink"
    153 ||Minimal support for garbage collection and reachability-based leak detection|| ||  N  ||  N  ||  N  ||  N  || ||
    154 }}}
    155 {{{#!tr style="background: LightGreen"
    156 ||Allowing move constructors to throw [noexcept]|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    157 }}}
    158 {{{#!tr style="background: LightGreen"
    159 ||Defining move special member functions|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    160 }}}
     17||= '''#''' =||= '''Name''' =||= '''Example''' =||
     18|| P1771R1 || [[nodiscard]] for constructors || ||
     19|| P0961R1 || Relaxing the structured bindings customization point finding rules || ||
     20|| P0969R0 || Allowing structured bindings to accessible members        || ||
     21|| P0588R1 || Simplifying implicit lambda capture || ||
     22|| P1825R0 || Merged wording for P0527R1 and P1155R3, more implicit moves || ||
     23|| P0929R2 || Checking for abstract class types || ||
     24|| P0962R2 || Relaxing the range-for loop customization point finding rules || ||
     25|| P0859R0 || CWG 1581: When are constexpr member functions defined || ||
     26|| P1009R2 || Array size deduction in new-expressions || ||
     27|| P1286R2 || Contra CWG DR1778 || ||
    16128
    162 == C++11 Core Language Features: Concurrency ==
    163 
    164 ||= Feature =||= Example =||= GCC 4.8.1 =||= Clang 3.4 =||= VS 2015 =||= '''0 A.D. Support''' =||= Notes =||
    165 {{{#!tr style="background: LightGreen"
    166 ||Revised sequence points|| ||  Y  ||  Y  ||  Y  ||  Y  || [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2239.html N2239] ||
    167 }}}
    168 {{{#!tr style="background: LightGreen"
    169 ||Atomic operations|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    170 }}}
    171 {{{#!tr style="background: LightGreen"
    172 ||Bidirectional Fences|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    173 }}}
    174 {{{#!tr style="background: LightGreen"
    175 ||Memory model|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    176 }}}
    177 {{{#!tr style="background: LightGreen"
    178 ||Data-dependency ordering: atomics and memory model|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    179 }}}
    180 {{{#!tr style="background: LightGreen"
    181 ||Propagating exceptions|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    182 }}}
    183 {{{#!tr style="background: LightGreen"
    184 ||Abandoning a process and at_quick_exit|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    185 }}}
    186 {{{#!tr style="background: LightGreen"
    187 ||Allow atomics use in signal handlers|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    188 }}}
    189 {{{#!tr style="background: LightGreen"
    190 ||Thread-local storage|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    191 }}}
    192 {{{#!tr style="background: LightGreen"
    193 ||Dynamic initialization and destruction with concurrency|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    194 }}}
    195 
    196 == C++11 Core Language Features: C99 ==
    197 
    198 ||= Feature =||= Example =||= GCC 4.8.1 =||= Clang 3.4 =||= VS 2015 =||= '''0 A.D. Support''' =||= Notes =||
    199 {{{#!tr style="background: LightGreen"
    200 ||!__func!__ predefined identifier|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    201 }}}
    202 {{{#!tr style="background: LightYellow"
    203 ||C99 preprocessor|| ||  Y  ||  Y  ||  P  ||  P  || VS 2015 has partial support (Variadic macros are supported) ||
    204 }}}
    205 {{{#!tr style="background: LightGreen"
    206 ||long long|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
    207 }}}
    208 {{{#!tr style="background: Pink"
    209 ||Extended integral types|| ||  Y  ||  N  ||  N  ||  N  || ||
    210 }}}
    211 
    212 = References =
    213 
    214 1. C++11 Support in GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx11
    215 1. Support For C++11 Features (Modern C++) in Visual C++: https://msdn.microsoft.com/en-us/library/hh567368.aspx
    216 1. C++ Support in Clang: http://clang.llvm.org/cxx_status.html
    217 1. C++11/14 Core Language Features in VS 2013 and the Nov 2013 CTP: http://blogs.msdn.com/b/vcblog/archive/2013/12/02/c-11-14-core-language-features-in-vs-2013-and-the-nov-2013-ctp.aspx
    218 1. Using C++ in Mozilla code: https://developer.mozilla.org/en-US/docs/Using_CXX_in_Mozilla_code
    219 1. Xcode Version Information: https://trac.macports.org/wiki/XcodeVersionInfo
    220 1. C++11 support in compilers: http://www.klayge.org/wiki/index.php/C%2B%2B11_support_in_compilers
    221 1. Expression SFINAE improvements in VS 2015 Update 3: https://devblogs.microsoft.com/cppblog/expression-sfinae-improvements-in-vs-2015-update-3/
     29There are nice features and should not be a concern in general. Note though that `[[nodiscard]]` cannot be used on constructors.