Skip to content

Commit

Permalink
PR #1801: Remove unncessary <iostream> includes
Browse files Browse the repository at this point in the history
Imported from GitHub PR #1801

Including `<iostream>` 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 4207b23 into f339ea3

Merging this change closes #1801

COPYBARA_INTEGRATE_REVIEW=#1801 from jwnimmer-tri:iostream 4207b23
PiperOrigin-RevId: 712548264
Change-Id: Ia04b581753622d357d3e989d0b1ae6d938fd7335
  • Loading branch information
jwnimmer-tri authored and copybara-github committed Jan 6, 2025
1 parent 51b7426 commit 3ee08f3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion absl/random/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions absl/random/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ absl_cc_library(
${ABSL_DEFAULT_LINKOPTS}
DEPS
absl::config
absl::raw_logging_internal
)

absl_cc_library(
Expand Down
3 changes: 2 additions & 1 deletion absl/random/internal/randen_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
#include <algorithm>
#include <cinttypes>
#include <cstdlib>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <ostream>
#include <type_traits>

#include "absl/base/internal/endian.h"
Expand Down
5 changes: 2 additions & 3 deletions absl/random/seed_gen_exception.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@

#include "absl/random/seed_gen_exception.h"

#include <iostream>

#include "absl/base/config.h"
#include "absl/base/internal/raw_logging.h"

namespace absl {
ABSL_NAMESPACE_BEGIN
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion absl/strings/internal/charconv_bigint.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <ostream>
#include <string>

#include "absl/base/config.h"
Expand Down

0 comments on commit 3ee08f3

Please sign in to comment.