Skip to content

Commit

Permalink
Alter test for std::put_time to work on clang+libstdc++
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Dec 16, 2016
1 parent a84a309 commit dab5d57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/gettext_boost.cpp
Expand Up @@ -436,7 +436,8 @@ std::string strftime(const std::string& format, const std::tm* time)
{
std::basic_ostringstream<char> dummy;
dummy.imbue(get_manager().get_locale());
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
// See utils/io.hpp for explanation of this check
#if (defined(__clang__) && !__has_include(<experimental/any>) || (defined(__GNUC__) && __GNUC__ < 5)
dummy << bl::as::ftime(format) << mktime(const_cast<std::tm*>(time));
#else
dummy << std::put_time(time, format.c_str());
Expand Down
8 changes: 7 additions & 1 deletion src/utils/io.hpp
Expand Up @@ -11,7 +11,13 @@ but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/

#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
// The version of libstdc++ shipped with GCC 4.x does not have put_time in the <iomanip> header
// Thus if GCC is the compiler being used, we can simply check the compiler version.
// However, if clang is being used, this won't work.
// Instead, we check for the presence of the <experimental/any> header.
// This was introduced in GCC 5.1, so it's not a perfect check, but it appears to be the best available.
// (Boost also uses the same check internally.)
#if (defined(__clang__) && !__has_include(<experimental/any>) || (defined(__GNUC__) && __GNUC__ < 5)

#include <ctime>

Expand Down

0 comments on commit dab5d57

Please sign in to comment.