diff options
author | Chris Robinson <[email protected]> | 2018-10-28 17:42:20 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-10-29 10:10:37 -0700 |
commit | 7d5a288e832b34e0117e1b1d7753847cf17f7e01 (patch) | |
tree | 29cd84cd8dc7763441faae50b916dbf1250b955f /Alc/polymorphism.h | |
parent | 1d7b0f54bee766d685ab74f0c206547431f4f636 (diff) |
Add a couple casts for compiling with C++
Also avoid using __builtin_types_compatible_p, which seems broken with C++?
Diffstat (limited to 'Alc/polymorphism.h')
-rw-r--r-- | Alc/polymorphism.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Alc/polymorphism.h b/Alc/polymorphism.h index fa31fad2..e837b2a5 100644 --- a/Alc/polymorphism.h +++ b/Alc/polymorphism.h @@ -4,7 +4,7 @@ /* Macros to declare inheriting types, and to (down-)cast and up-cast. */ #define DERIVE_FROM_TYPE(t) t t##_parent #define STATIC_CAST(to, obj) (&(obj)->to##_parent) -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__cplusplus) #define STATIC_UPCAST(to, from, obj) __extension__({ \ static_assert(__builtin_types_compatible_p(from, __typeof(*(obj))), \ "Invalid upcast object from type"); \ @@ -74,14 +74,14 @@ static void T##_Delete(void *ptr) { al_free(ptr); } /* Allocate and construct an object, with arguments. */ #define NEW_OBJ(_res, T) do { \ - _res = T##_New(sizeof(T)); \ + _res = (T*)T##_New(sizeof(T)); \ if(_res) \ { \ memset(_res, 0, sizeof(T)); \ T##_Construct(_res, EXTRACT_NEW_ARGS /* Allocate and construct an object, with no arguments. */ #define NEW_OBJ0(_res, T) do { \ - _res = T##_New(sizeof(T)); \ + _res = (T*)T##_New(sizeof(T)); \ if(_res) \ { \ memset(_res, 0, sizeof(T)); \ |