diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-07-15 07:51:20 -0400 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.com> | 2020-10-14 14:52:41 -0400 |
commit | 0d81443ec025b832d3f072a25bdc8e74c13a3919 (patch) | |
tree | 5ca08c7fe37dcff058588c9dd3f7458b1e430483 /glib/gmacros.h | |
parent | 3028e6a9676b876ab40ca71f1352ff3305098694 (diff) | |
download | glib-0d81443ec025b832d3f072a25bdc8e74c13a3919.tar.gz |
Use C++11 decltype where possible
There are various places glib uses __typeof__ for type safety, but
that's a GNUC extension. C++11 has standard decltype() that does a
similar job, at least for cases we care about.
This avoids C++ code to always have to cast return value of
g_object_ref() which was causing type kind of error:
error: invalid conversion from ‘gpointer’ {aka ‘void*’} to
‘GstElementFactory*’ {aka ‘_GstElementFactory*’} [-fpermissive]
Diffstat (limited to 'glib/gmacros.h')
-rw-r--r-- | glib/gmacros.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/glib/gmacros.h b/glib/gmacros.h index 01139b271..0dd9a41c2 100644 --- a/glib/gmacros.h +++ b/glib/gmacros.h @@ -234,6 +234,10 @@ #undef glib_typeof #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) && !defined(__cplusplus) #define glib_typeof(t) __typeof__ (t) +#elif defined(__cplusplus) && __cplusplus >= 201103L +/* C++11 decltype() is close enough for our usage */ +#include <type_traits> +#define glib_typeof(t) std::remove_reference<decltype (t)>::type #endif /* |