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.

Supported Compilers

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:

  • GCC 4.8.1 or newer
  • Clang 3.4 or newer
  • Visual Studio 2013

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.

Code examples are given for many features as the formal names can be unclear.

C++11 Core Language Features

Feature Example GCC 4.8.1 Clang 3.4 VS 2013 0 A.D. Support Notes
Emplacementemplace, emplace_back Y Y Y Y
Rvalue referencestype_t && Y Y P Y VS 2013 has partial support
Rvalue references for *thisvoid RValueFunc() &&; Y Y N N
Initialization of class objects by rvalues Y Y Y Y
Non-static data member initializersclass Foo{ public: int bar=7; }; Y Y Y Y
Variadic templatestemplate<typename T, typename... Args> Y Y Y Y
Extending variadic template template parameters Y Y Y Y
Initializer listsvector<int> v = { 1, 2, 3, 4, 5, 6 }; Y Y Y Y
Static assertionsstatic_assert(expression,message); Y Y Y Y
auto-typed variables for (auto p = v.begin(); p!=v.end(); ++p) Y Y Y Y
Multi-declarator autofor (auto p = v.begin(), e=v.end(); p!=e; ++p) Y Y Y Y
Removal of auto as a storage-class specifierauto int r; Y Y Y Y
New function declarator syntax Y Y Y Y
New wording for C++0x lambdas Y Y Y Y
Declared type of an expressiontypedef decltype(a[0]*b[0]) Tmp; Y Y Y Y
Incomplete return types Y Y Y Y
Right angle bracketslist<vector<string>> lvs; Y Y Y Y
Default template arguments for function templates Y Y Y Y
Solving the SFINAE problem for expressions Y Y N N
Template aliasestemplate<class T> using Vec = vector<T,My_alloc<T>>; Y Y Y Y
Extern templatesextern template class Foo<int>; Y Y Y Y
Null pointer constantchar* p = nullptr; Y Y Y Y
Strongly-typed enumsenum foo : int {}; Y Y Y Y
Forward declarations for enumsenum class Foo : char; Y Y Y Y
Generalized attributes[[attributes]] Y Y N N
Generalized constant expressionsconstexpr int a = b.x; Y Y N N
Alignment supportalignas(16) char[100]; Y Y P P
Delegating constructors Y Y Y Y
Inheriting constructors Y Y N N
Explicit conversion operatorsexplicit operator bool() Y Y Y Y
New character typeschar16_t / char32_t Y Y N N
Unicode string literalsu"string" Y Y N N
Raw string literals r"\string!\"; Y Y Y Y
Universal character name literals Y Y N N
Extensible literalsstd::string operator""s (const char* p, size_t n) Y Y N N
Standard Layout Typesstruct Foo { int a; Foo(int aa) : a(aa) { } }; Y Y Y Y
Defaulted and deleted functionsX& operator=(const X&) = delete; Y Y Y Y
Extended friend declarations Y Y Y Y
Extending sizeof Y Y N N
Inline namespaces Y Y N N
Unrestricted unions Y Y N N
Local and unnamed types as template arguments Y Y Y Y
Range-based forfor (auto x : vec) Y Y Y Y
Explicit virtual overridesvoid f() override; Y Y Y Y
Minimal support for garbage collection and reachability-based leak detection N N Y N
Allowing move constructors to throw [noexcept] Y Y N N
Defining move special member functions Y Y N N

C++11 Core Language Features: Concurrency

Feature Example GCC 4.8.1 Clang 3.4 VS 2013 0 A.D. Support Notes
Sequence points Y Y N N
Atomic operations Y Y Y Y
Bidirectional Fences Y Y Y Y
Memory model Y Y N N
Data-dependency ordering: atomics and memory model Y Y Y Y
Propagating exceptions Y Y Y Y
Abandoning a process and at_quick_exit Y Y N N
Allow atomics use in signal handlers Y Y N N
Thread-local storage Y Y P P
Dynamic initialization and destruction with concurrency Y Y N N

C++11 Core Language Features: C99

Feature Example GCC 4.8.1 Clang 3.4 VS 2013 0 A.D. Support Notes
__func__ predefined identifier Y Y P N
C99 preprocessor Y Y P Y VS 2013 has partial support (Variadic macros are supported)
long long Y Y Y Y
Extended integral types Y N N N

References

  1. C++11 Support in GCC: https://gcc.gnu.org/projects/cxx-status.html#cxx11
  2. Support For C++11 Features (Modern C++) in Visual C++: https://msdn.microsoft.com/en-us/library/hh567368.aspx
  3. C++ Support in Clang: http://clang.llvm.org/cxx_status.html
  4. 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
  5. Using C++ in Mozilla code: https://developer.mozilla.org/en-US/docs/Using_CXX_in_Mozilla_code
  6. Xcode Version Information: https://trac.macports.org/wiki/XcodeVersionInfo
  7. C++11 support in compilers: http://www.klayge.org/wiki/index.php/C%2B%2B11_support_in_compilers
Last modified 5 months ago Last modified on Mar 6, 2017, 7:17:01 PM