diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-09 20:23:21 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-03-13 14:47:40 +0300 |
commit | 63ea8dd156b39eb57b73a953f5ac9ae54b7a447a (patch) | |
tree | 768a5dbb95f7a4b50f7f9e857beedd27f3c0175b /source/blender/blenlib | |
parent | 278871db5bdef68cf128dd01fb9c722db55054e3 (diff) |
Initial compilation support with C++11 featureset enabled
This commit makes some preliminary fixes and tweaks aimed to make blender
compilable with C++11 feature set. This includes:
- Build system attribute to enable C++11 featureset.
It's for sure default OFF, but easy to enable to have a play around with
it and make sure all the stuff is compilable before we go C++11 for real.
- Changes in Compositor to use non-named cl_int structure fields.
This is because __STRICT_ANSI__ is defined by default by GCC and OpenCL
does not use named fields in this case.
- Changes to TYPE_CHECK() related on lack of typeof() in C++11
This uses decltype() instead with some trickery to make sure returned type
is not a reference.
- Changes for auto_ptr in Freestyle
This actually conditionally switches between auto_ptr and unique_ptr since
auto_ptr is deprecated in C++11. Seems to be not strictly needed but still
nice to be ready for such an update anyway/
This all based on changes form depsgraph_refactor branch apart from the weird
changes which were made in order to support MinGW compilation. Those parts of
change would need to be carefully reviewed again after official move to gcc49
in MinGW.
Tested on Linux with GCC-4.7 and Clang-3.5, other platforms are not tested and
likely needs some more tweaks.
Reviewers: campbellbarton, juicyfruit, mont29, lukastoenne, psy-fi, kjym3
Differential Revision: https://developer.blender.org/D1089
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_compiler_compat.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_compiler_compat.h b/source/blender/blenlib/BLI_compiler_compat.h index 10c0752c9a7..876d2c459c5 100644 --- a/source/blender/blenlib/BLI_compiler_compat.h +++ b/source/blender/blenlib/BLI_compiler_compat.h @@ -37,4 +37,16 @@ # include <malloc.h> #endif +#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800)) +# define HAS_CPP11_FEATURES +#endif + +#if (defined(__GNUC__) || defined(__clang__)) && defined(HAS_CPP11_FEATURES) +extern "C++" { + /* Some magic to be sure we don't have reference in the type. */ + template<typename T> static inline T decltype_helper(T x) { return x; } +# define typeof(x) decltype(decltype_helper(x)) +} +#endif + #endif /* __BLI_COMPILER_COMPAT_H__ */ |