🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

GCC 5.1 Deprecated warnings

Started by
2 comments, last by WitchLord 9 years, 1 month ago

Hi,

Compiling the latest angelscript release "2.30.0 WIP" with GCC 5.1 (in c++14 mode) gives these warnings:


/home/hhyyrylainen/leviathan/AngelScript/include/angelscript.h: Funktio ”asUINT asGetTypeTraits()”:

/home/hhyyrylainen/leviathan/AngelScript/include/angelscript.h:597:80: varoitus: ”template<class _Tp> struct std::has_trivial_default_constructor” is deprecated [-Wdeprecated-declarations]

  bool hasConstructor        = std::is_default_constructible<T>::value && !std::has_trivial_defaul

                                                                                ^

In file included from /usr/include/c++/5.1.1/bits/move.h:57:0,

                 from /usr/include/c++/5.1.1/bits/stl_pair.h:59,

                 from /usr/include/c++/5.1.1/bits/stl_algobase.h:64,

                 from /usr/include/c++/5.1.1/bits/char_traits.h:39,

                 from /usr/include/c++/5.1.1/string:40,

                 from /home/hhyyrylainen/leviathan/Engine/Define.h:13,

                 from /home/hhyyrylainen/leviathan/Engine/Engine.h:3,

                 from /home/hhyyrylainen/leviathan/Engine/Engine.cpp:2:

/usr/include/c++/5.1.1/type_traits:1383:12: huom: esitelty täällä

     struct has_trivial_default_constructor

            ^

In file included from /home/hhyyrylainen/leviathan/Engine/Script/ScriptExecutor.h:11:0,

                 from /home/hhyyrylainen/leviathan/Engine/Application/Application.h:7,

                 from /home/hhyyrylainen/leviathan/Engine/Engine.cpp:6:

/home/hhyyrylainen/leviathan/AngelScript/include/angelscript.h:599:80: varoitus: ”template<class _Tp> struct std::has_trivial_copy_assign” is deprecated [-Wdeprecated-declarations]

  bool hasAssignmentOperator = std::is_copy_assignable<T>::value       && !std::has_trivial_copy_a

 

More warnings: http://pastebin.com/1gc26Rnt

This should be a pretty easy fix, just renaming the functions to is_trivially_default_constructible.

Advertisement

So gnuc has finally caught up with the C++11 standard smile.png

Can you check if the following change in the angelscript.h header file works for you?

(The change is in the first #if condition, to have gnuc 5+ use the C++11 standards compliant code too.)


template<typename T>
asUINT asGetTypeTraits()
{
-#if defined(_MSC_VER) || defined(_LIBCPP_TYPE_TRAITS)
+#if defined(_MSC_VER) || defined(_LIBCPP_TYPE_TRAITS) || (__GNUC__ >= 5)
 // MSVC & XCode/Clang & gnuc 5+
 // C++11 compliant code
 bool hasConstructor        = std::is_default_constructible<T>::value && !std::is_trivially_default_constructible<T>::value;
 bool hasDestructor         = std::is_destructible<T>::value          && !std::is_trivially_destructible<T>::value;
 bool hasAssignmentOperator = std::is_copy_assignable<T>::value       && !std::is_trivially_copy_assignable<T>::value;
 bool hasCopyConstructor    = std::is_copy_constructible<T>::value    && !std::is_trivially_copy_constructible<T>::value;
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
 // gnuc 4.8+
 // gnuc is using a mix of C++11 standard and pre-standard templates
 bool hasConstructor        = std::is_default_constructible<T>::value && !std::has_trivial_default_constructor<T>::value;
 bool hasDestructor         = std::is_destructible<T>::value          && !std::is_trivially_destructible<T>::value;
 bool hasAssignmentOperator = std::is_copy_assignable<T>::value       && !std::has_trivial_copy_assign<T>::value;
 bool hasCopyConstructor    = std::is_copy_constructible<T>::value    && !std::has_trivial_copy_constructor<T>::value;
#else
 // Not fully C++11 compliant. The has_trivial checks were used while the standard was still
 // being elaborated, but were then removed in favor of the above is_trivially checks
 // http://stackoverflow.com/questions/12702103/writing-code-that-works-when-has-trivial-destructor-is-defined-instead-of-is
 // https://github.com/mozart/mozart2/issues/51
 bool hasConstructor        = std::is_default_constructible<T>::value && !std::has_trivial_default_constructor<T>::value;
 bool hasDestructor         = std::is_destructible<T>::value          && !std::has_trivial_destructor<T>::value;
 bool hasAssignmentOperator = std::is_copy_assignable<T>::value       && !std::has_trivial_copy_assign<T>::value;
 bool hasCopyConstructor    = std::is_copy_constructible<T>::value    && !std::has_trivial_copy_constructor<T>::value;
#endif
 bool isFloat     = std::is_floating_point<T>::value;
 bool isPrimitive = std::is_integral<T>::value || std::is_pointer<T>::value || std::is_enum<T>::value;
 bool isClass     = std::is_class<T>::value;
 bool isArray     = std::is_array<T>::value;
 if( isFloat )
  return asOBJ_APP_FLOAT;
 if( isPrimitive )
  return asOBJ_APP_PRIMITIVE;
 if( isClass )
 {
  asDWORD flags = asOBJ_APP_CLASS;
  if( hasConstructor )
   flags |= asOBJ_APP_CLASS_CONSTRUCTOR;
  if( hasDestructor )
   flags |= asOBJ_APP_CLASS_DESTRUCTOR;
  if( hasAssignmentOperator )
   flags |= asOBJ_APP_CLASS_ASSIGNMENT;
  if( hasCopyConstructor )
   flags |= asOBJ_APP_CLASS_COPY_CONSTRUCTOR;
  return flags;
 }
 if( isArray )
  return asOBJ_APP_ARRAY;
 // Unknown type traits
 return 0;
}

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

That fixed it, thanks.

Checked in to revision 2174.

Thanks,

Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement