From 3ee08f329825b3f68c988b212bffd332b58e4275 Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Mon, 6 Jan 2025 09:05:32 -0800 Subject: [PATCH] PR #1801: Remove unncessary includes Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1801 Including `` means introducing the static (global) constructors and destructors for `std::cin`, `std::cerr`, and `std::cout`. That extra `init` and `fini` code is [undesirable](https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables) when those streams are not actually used. Merge 4207b23cd481676abfee4476a66e0ae11d440298 into f339ea31b8dfc139075ba3feb4d848beaee5639e Merging this change closes #1801 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1801 from jwnimmer-tri:iostream 4207b23cd481676abfee4476a66e0ae11d440298 PiperOrigin-RevId: 712548264 Change-Id: Ia04b581753622d357d3e989d0b1ae6d938fd7335 --- absl/random/BUILD.bazel | 5 ++++- absl/random/CMakeLists.txt | 1 + absl/random/internal/randen_engine.h | 3 ++- absl/random/seed_gen_exception.cc | 5 ++--- absl/strings/internal/charconv_bigint.h | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/absl/random/BUILD.bazel b/absl/random/BUILD.bazel index 742ab76e6a8..ef8ac7ef602 100644 --- a/absl/random/BUILD.bazel +++ b/absl/random/BUILD.bazel @@ -93,7 +93,10 @@ cc_library( hdrs = ["seed_gen_exception.h"], copts = ABSL_DEFAULT_COPTS, linkopts = ABSL_DEFAULT_LINKOPTS, - deps = ["//absl/base:config"], + deps = [ + "//absl/base:config", + "//absl/base:raw_logging_internal", + ], ) cc_library( diff --git a/absl/random/CMakeLists.txt b/absl/random/CMakeLists.txt index 2e4f0e459f0..1d8464be97b 100644 --- a/absl/random/CMakeLists.txt +++ b/absl/random/CMakeLists.txt @@ -211,6 +211,7 @@ absl_cc_library( ${ABSL_DEFAULT_LINKOPTS} DEPS absl::config + absl::raw_logging_internal ) absl_cc_library( diff --git a/absl/random/internal/randen_engine.h b/absl/random/internal/randen_engine.h index fe2d9f6c159..925e1bbab55 100644 --- a/absl/random/internal/randen_engine.h +++ b/absl/random/internal/randen_engine.h @@ -18,9 +18,10 @@ #include #include #include -#include +#include #include #include +#include #include #include "absl/base/internal/endian.h" diff --git a/absl/random/seed_gen_exception.cc b/absl/random/seed_gen_exception.cc index fdcb54a86cd..6fb4ad37665 100644 --- a/absl/random/seed_gen_exception.cc +++ b/absl/random/seed_gen_exception.cc @@ -14,9 +14,8 @@ #include "absl/random/seed_gen_exception.h" -#include - #include "absl/base/config.h" +#include "absl/base/internal/raw_logging.h" namespace absl { ABSL_NAMESPACE_BEGIN @@ -36,7 +35,7 @@ void ThrowSeedGenException() { #ifdef ABSL_HAVE_EXCEPTIONS throw absl::SeedGenException(); #else - std::cerr << kExceptionMessage << std::endl; + ABSL_RAW_LOG(FATAL, "%s", kExceptionMessage); std::terminate(); #endif } diff --git a/absl/strings/internal/charconv_bigint.h b/absl/strings/internal/charconv_bigint.h index cb297676631..2c7a3366464 100644 --- a/absl/strings/internal/charconv_bigint.h +++ b/absl/strings/internal/charconv_bigint.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include "absl/base/config.h"