From 4c3f7931643ca4a87d6f2e084604182379449f7b Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Sat, 19 Oct 2019 16:19:10 +0000 Subject: [PATCH] Fix build after ccfbe8f (Report context of cache.log messages) (#495) In some environments (e.g., Ubuntu 14 without libcppunit-dev), GCC correctly complained that it does not know how to print "[unknown]", probably because none of the other headers imported `` before importing base/InstanceId.h. --- src/base/InstanceId.cc | 25 +++++++++++++++++++++++++ src/base/InstanceId.h | 12 +----------- src/base/Makefile.am | 1 + 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 src/base/InstanceId.cc diff --git a/src/base/InstanceId.cc b/src/base/InstanceId.cc new file mode 100644 index 0000000000..0507978aad --- /dev/null +++ b/src/base/InstanceId.cc @@ -0,0 +1,25 @@ +/* + * Copyright (C) 1996-2019 The Squid Software Foundation and contributors + * + * Squid software is distributed under GPLv2+ license and includes + * contributions from numerous individuals and organizations. + * Please see the COPYING and CONTRIBUTORS files for details. + */ + +#include "squid.h" +#include "base/InstanceId.h" + +#include + +std::ostream& +operator <<(std::ostream &os, const ScopedId &id) +{ + if (id.value) + os << id.scope << id.value; + else if (id.scope) + os << id.scope; + else + os << "[unknown]"; + return os; +} + diff --git a/src/base/InstanceId.h b/src/base/InstanceId.h index f5fcfbca96..d8f9251bb0 100644 --- a/src/base/InstanceId.h +++ b/src/base/InstanceId.h @@ -32,17 +32,7 @@ public: uint64_t value; }; -inline std::ostream& -operator <<(std::ostream &os, const ScopedId &id) -{ - if (id.value) - os << id.scope << id.value; - else if (id.scope) - os << id.scope; - else - os << "[unknown]"; - return os; -} +std::ostream &operator <<(std::ostream &os, const ScopedId &id); typedef unsigned int InstanceIdDefaultValueType; /** Identifier for class instances diff --git a/src/base/Makefile.am b/src/base/Makefile.am index c891b4f819..ea403a1a21 100644 --- a/src/base/Makefile.am +++ b/src/base/Makefile.am @@ -33,6 +33,7 @@ libbase_la_SOURCES = \ HardFun.h \ Here.cc \ Here.h \ + InstanceId.cc \ InstanceId.h \ Lock.h \ LookupTable.h \ -- 2.47.2