Skip to content

Commit

Permalink
Offer alternative for cxxabi on Windows (Swift+Clang).
Browse files Browse the repository at this point in the history
* This fixes the clang compilation of OpenTimelineIO on Windows, when compiling with Swift.
  • Loading branch information
furby-tm committed Jul 29, 2024
1 parent d213805 commit aeb0ce9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/opentimelineio/stringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
#include "opentimelineio/serializableObject.h"
#if defined(__GNUC__) || defined(__clang__)
# include <cstdlib>
# include <cxxabi.h>
# if __has_include(<cxxabi.h>)
# define OTIO_HAVE_DEMANGLER 1
# include <cxxabi.h>
# else // !__has_include(<cxxabi.h>)
# define OTIO_HAVE_DEMANGLER 0
# endif // __has_include(<cxxabi.h>)
# include <memory>
#else
# include <typeinfo>
#endif

namespace {
#if defined(__GNUC__) || defined(__clang__)
#if OTIO_HAVE_DEMANGLER
std::string
cxxabi_type_name_for_error_mesage(const char* name)
{
Expand Down Expand Up @@ -41,10 +46,10 @@ type_name_for_error_message(std::type_info const& t)
return "None";
}

#if defined(__GNUC__) || defined(__clang__)
#if OTIO_HAVE_DEMANGLER
return ::cxxabi_type_name_for_error_mesage(t.name());
#else
// On Windows std::type_info.name() returns a human readable string.
// On Windows, or without cxxabi.h, std::type_info.name() returns a human readable string.
return t.name();
#endif
}
Expand Down

0 comments on commit aeb0ce9

Please sign in to comment.