Changes between Initial Version and Version 1 of CppSupport


Ignore:
Timestamp:
Jan 26, 2015, 4:34:07 AM (9 years ago)
Author:
historic_bruno
Comment:

Initial WIP version - please check, proofread, discuss, correct, and add missing details :)

Legend:

Unmodified
Added
Removed
Modified
  • CppSupport

    v1 v1  
     1
     2This page will attempt to describe features of modern C++ standards (C++0x, C++11, C++14, etc.) supported by the game. For information on building the game, see BuildInstructions.
     3
     4= Supported Compilers =
     5
     60 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.6 or newer
     8 * Clang 3.1 or newer
     9  * Shipped with Xcode 4.3.3 on OS X
     10  * '''Note:''' older versions may work, but this isn't guaranteed
     11 * Visual Studio 2013
     12
     13The following tables summarize C++1x 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.
     14
     15Code examples are given for many features as the formal names can be unclear.
     16
     17= C++11 Core Language Features =
     18
     19||= Feature =||= Example =||= GCC 4.6 =||= Clang 3.1 =||= VS 2013 =||= '''0 A.D. Support''' =||= Notes =||
     20{{{#!tr style="background: LightYellow"
     21||Rvalue references||`type_t &&`||  Y  ||  Y  ||  P  ||  Y  || VS 2013 has [https://msdn.microsoft.com/en-us/library/hh567368.aspx#rvref partial] support ||
     22}}}
     23{{{#!tr style="background: Pink"
     24||Rvalue references for *this||`void RValueFunc() &&;`||  N  ||  N  ||  N  ||  N  || ||
     25}}}
     26{{{#!tr style="background: LightGreen"
     27||Initialization of class objects by rvalues|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
     28}}}
     29{{{#!tr style="background: Pink"
     30||Non-static data member initializers||`class Foo{ public: int bar=7; };`||  N  ||  Y  ||  Y  ||  N  || ||
     31}}}
     32{{{#!tr style="background: LightGreen"
     33||Variadic templates||`template<typename T, typename... Args>`||  Y  ||  Y  ||  Y  ||  Y  || ||
     34}}}
     35{{{#!tr style="background: LightGreen"
     36||Extending variadic template template parameters|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
     37}}}
     38{{{#!tr style="background: LightGreen"
     39||Initializer lists||`vector<int> v = { 1, 2, 3, 4, 5, 6 };`||  Y  ||  Y  ||  Y  ||  Y  || ||
     40}}}
     41{{{#!tr style="background: LightGreen"
     42||Static assertions||`static_assert(expression,message);`||  Y  ||  Y  ||  Y  ||  Y  || ||
     43}}}
     44{{{#!tr style="background: LightGreen"
     45||auto-typed variables|| `for (auto p = v.begin(); p!=v.end(); ++p)` ||  Y  ||  Y  ||  Y  ||  Y  || ||
     46}}}
     47{{{#!tr style="background: LightGreen"
     48||Multi-declarator auto||`for (auto p = v.begin(), e=v.end(); p!=e; ++p)`||  Y  ||  Y  ||  Y  ||  Y  || ||
     49}}}
     50{{{#!tr style="background: LightGreen"
     51||Removal of auto as a storage-class specifier||~~`auto int r;`~~||  Y  ||  Y  ||  Y  ||  Y  || ||
     52}}}
     53{{{#!tr style="background: LightGreen"
     54||New function declarator syntax|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
     55}}}
     56{{{#!tr style="background: LightGreen"
     57||New wording for C++0x lambdas|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
     58}}}
     59{{{#!tr style="background: LightGreen"
     60||Declared type of an expression||`typedef decltype(a[0]*b[0]) Tmp;`||  Y  ||  Y  ||  Y  ||  Y  || ||
     61}}}
     62{{{#!tr style="background: Pink"
     63||Incomplete return types|| ||  N  ||  Y  ||  Y  ||  N  || ||
     64}}}
     65{{{#!tr style="background: LightGreen"
     66||Right angle brackets||`list<vector<string>> lvs;`||  Y  ||  Y  ||  Y  ||  Y  || ||
     67}}}
     68{{{#!tr style="background: LightGreen"
     69||Default template arguments for function templates|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
     70}}}
     71{{{#!tr style="background: Pink"
     72||Solving the SFINAE problem for expressions|| ||  Y  ||  Y  ||  N  ||  N  || ||
     73}}}
     74{{{#!tr style="background: Pink"
     75||Template aliases||`template<class T> using Vec = vector<T,My_alloc<T>>;`||  N  ||  Y  ||  Y  ||  N  || ||
     76}}}
     77{{{#!tr style="background: LightGreen"
     78||Extern templates||`extern template class Foo<int>;`||  Y  ||  Y  ||  Y  ||  Y  || ||
     79}}}
     80{{{#!tr style="background: LightGreen"
     81||Null pointer constant||`char* p = nullptr;`||  Y  ||  Y  ||  Y  ||  Y  || ||
     82}}}
     83{{{#!tr style="background: LightGreen"
     84||Strongly-typed enums||`enum foo : int {};`||  Y  ||  Y  ||  Y  ||  Y  || ||
     85}}}
     86{{{#!tr style="background: LightGreen"
     87||Forward declarations for enums||`enum class Foo : char;`||  Y  ||  Y  ||  Y  ||  Y  || ||
     88}}}
     89{{{#!tr style="background: Pink"
     90||Generalized attributes||`[[attributes]]`||  N  ||  N  ||  N  ||  N  || ||
     91}}}
     92{{{#!tr style="background: Pink"
     93||Generalized constant expressions||`constexpr int a = b.x;`||  Y  ||  Y  ||  N  ||  N  || ||
     94}}}
     95{{{#!tr style="background: Pink"
     96||Alignment support||`alignas(16) char[100];`||  N  ||  N  ||  P  ||  N  || ||
     97}}}
     98{{{#!tr style="background: Pink"
     99||Delegating constructors|| ||  N  ||  Y  ||  Y  ||  N  || ||
     100}}}
     101{{{#!tr style="background: Pink"
     102||Inheriting constructors|| ||  N  ||  N  ||  N  ||  N  || ||
     103}}}
     104{{{#!tr style="background: LightGreen"
     105||Explicit conversion operators||`explicit operator bool()`||  Y  ||  Y  ||  Y  ||  Y  || ||
     106}}}
     107{{{#!tr style="background: Pink"
     108||New character types||`char16_t` / `char32_t`||  Y  ||  Y  ||  N  ||  N  || ||
     109}}}
     110{{{#!tr style="background: Pink"
     111||Unicode string literals||`u"string"`||  Y  ||  Y  ||  N  ||  N  || ||
     112}}}
     113{{{#!tr style="background: LightGreen"
     114||Raw string literals||` r"\string!\";`||  Y  ||  Y  ||  Y  ||  Y  || ||
     115}}}
     116{{{#!tr style="background: Pink"
     117||Universal character name literals|| ||  Y  ||  Y  ||  N  ||  N  || ||
     118}}}
     119{{{#!tr style="background: Pink"
     120||Extensible literals||`std::string operator""s (const char* p, size_t n)`||  N  ||  Y  ||  N  ||  N  || ||
     121}}}
     122{{{#!tr style="background: LightGreen"
     123||Standard Layout Types||`struct Foo { int a; Foo(int aa) : a(aa) { } };`||  Y  ||  Y  ||  Y  ||  Y  || ||
     124}}}
     125{{{#!tr style="background: LightGreen"
     126||Defaulted and deleted functions||`X& operator=(const X&) = delete;`||  Y  ||  Y  ||  Y  ||  Y  || ||
     127}}}
     128{{{#!tr style="background: Pink"
     129||Extended friend declarations|| ||  N  ||  Y  ||  Y  ||  N  || ||
     130}}}
     131{{{#!tr style="background: Pink"
     132||Extending sizeof|| ||  Y  ||  Y  ||  N  ||  N  || ||
     133}}}
     134{{{#!tr style="background: Pink"
     135||Inline namespaces|| ||  Y  ||  Y  ||  N  ||  N  || ||
     136}}}
     137{{{#!tr style="background: Pink"
     138||Unrestricted unions|| ||  Y  ||  Y  ||  N  ||  N  || ||
     139}}}
     140{{{#!tr style="background: LightGreen"
     141||Local and unnamed types as template arguments|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
     142}}}
     143{{{#!tr style="background: LightGreen"
     144||Range-based for||`for (auto x : vec)`||  Y  ||  Y  ||  Y  ||  Y  || ||
     145}}}
     146{{{#!tr style="background: Pink"
     147||Explicit virtual overrides||`void f() override;`||  N  ||  Y  ||  Y  ||  N  || ||
     148}}}
     149{{{#!tr style="background: Pink"
     150||Minimal support for garbage collection and reachability-based leak detection|| ||  N  ||  N  ||  Y  ||  N  || ||
     151}}}
     152{{{#!tr style="background: Pink"
     153||Allowing move constructors to throw [noexcept]|| ||  Y  ||  Y  ||  N  ||  N  || ||
     154}}}
     155{{{#!tr style="background: Pink"
     156||Defining move special member functions|| ||  Y  ||  Y  ||  N  ||  N  || ||
     157}}}
     158
     159== C++11 Core Language Features: Concurrency ==
     160
     161||= Feature =||= Example =||= GCC 4.6 =||= Clang 3.1 =||= VS 2013 =||= '''0 A.D. Support''' =||= Notes =||
     162{{{#!tr style="background: Pink"
     163||Sequence points|| ||  N  ||  N  ||  N  ||  N  || ||
     164}}}
     165{{{#!tr style="background: LightGreen"
     166||Atomic operations|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
     167}}}
     168{{{#!tr style="background: Pink"
     169||Bidirectional Fences|| ||  N  ||  Y  ||  Y  ||  N  || ||
     170}}}
     171{{{#!tr style="background: Pink"
     172||Memory model|| ||  N  ||  N  ||  N  ||  N  || ||
     173}}}
     174{{{#!tr style="background: Pink"
     175||Data-dependency ordering: atomics and memory model|| ||  N  ||  N  ||  Y  ||  N  || ||
     176}}}
     177{{{#!tr style="background: LightGreen"
     178||Propagating exceptions|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
     179}}}
     180{{{#!tr style="background: Pink"
     181||Abandoning a process and at_quick_exit|| ||  N  ||  N  ||  N  ||  N  || ||
     182}}}
     183{{{#!tr style="background: Pink"
     184||Allow atomics use in signal handlers|| ||  N  ||  Y  ||  N  ||  N  || ||
     185}}}
     186{{{#!tr style="background: Pink"
     187||Thread-local storage|| ||  N  ||  N  ||  P  ||  N  || ||
     188}}}
     189{{{#!tr style="background: Pink"
     190||Dynamic initialization and destruction with concurrency|| ||  N  ||  N  ||  N  ||  N  || ||
     191}}}
     192
     193== C++11 Core Language Features: C99 ==
     194
     195||= Feature =||= Example =||= GCC 4.6 =||= Clang 3.1 =||= VS 2013 =||= '''0 A.D. Support''' =||= Notes =||
     196{{{#!tr style="background: Pink"
     197||!__func!__ predefined identifier|| ||  Y  ||  Y  ||  P  ||  N  || ||
     198}}}
     199{{{#!tr style="background: LightYellow"
     200||C99 preprocessor|| ||  Y  ||  Y  ||  P  ||  Y  || VS 2013 has partial support ||
     201}}}
     202{{{#!tr style="background: LightGreen"
     203||long long|| ||  Y  ||  Y  ||  Y  ||  Y  || ||
     204}}}
     205{{{#!tr style="background: Pink"
     206||Extended integral types|| ||  N  ||  N  ||  N  ||  N  || ||
     207}}}
     208
     209= References =
     210
     2111. C++0x/C++11 Support in GCC: https://gcc.gnu.org/projects/cxx0x.html
     2121. Support For C++11 Features (Modern C++) in Visual C++: https://msdn.microsoft.com/en-us/library/hh567368.aspx
     2131. C++ Support in Clang: http://clang.llvm.org/cxx_status.html
     2141. 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
     2151. Using C++ in Mozilla code: https://developer.mozilla.org/en-US/docs/Using_CXX_in_Mozilla_code
     2161. Xcode Version Information: https://trac.macports.org/wiki/XcodeVersionInfo
     2171. C++11 support in compilers: http://www.klayge.org/wiki/index.php/C%2B%2B11_support_in_compilers