From: Phil Willoughby Date: Thu, 10 Nov 2016 12:09:21 +0000 (-0800) Subject: Use std::cerr for folly/Singleton.cpp error printing X-Git-Tag: v2016.11.14.00~14 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=a500df075cf4bec7eaf604b3d85ff597ab5f5f0e Use std::cerr for folly/Singleton.cpp error printing Summary: Create a local std::ios_base::Init instance to ensure that it is valid, then use std::cerr. Reviewed By: yfeldblum, nbronson Differential Revision: D4139681 fbshipit-source-id: 03377dd417710e320a6b53298d507fd0168592f6 --- diff --git a/folly/Singleton.cpp b/folly/Singleton.cpp index fe8d7db7..5e89442c 100644 --- a/folly/Singleton.cpp +++ b/folly/Singleton.cpp @@ -19,10 +19,9 @@ #include #include #include -#include +#include #include -#include #include namespace folly { @@ -31,13 +30,12 @@ namespace detail { [[noreturn]] void singletonWarnDoubleRegistrationAndAbort( const TypeDescriptor& type) { - // Not using LOG(FATAL) or std::cerr because they may not be initialized yet. - std::ostringstream o; - o << "Double registration of singletons of the same " - << "underlying type; check for multiple definitions " - << "of type folly::Singleton<" << type.name() << ">" << std::endl; - auto s = o.str(); - writeFull(STDERR_FILENO, s.data(), s.size()); + // Ensure the availability of std::cerr + std::ios_base::Init ioInit; + std::cerr << "Double registration of singletons of the same " + "underlying type; check for multiple definitions " + "of type folly::Singleton<" + << type.name() << ">\n"; std::abort(); } }