From a500df075cf4bec7eaf604b3d85ff597ab5f5f0e Mon Sep 17 00:00:00 2001 From: Phil Willoughby Date: Thu, 10 Nov 2016 04:09:21 -0800 Subject: [PATCH] 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 --- folly/Singleton.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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(); } } -- 2.34.1