From 0041bfc41bd06f4e039854240efe2db23cd4d0bb Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 2 Mar 2020 15:12:05 +0100 Subject: [PATCH] Fix two 64 bit warnings by converting to long long unsigned --- include/deal.II/lac/la_vector.templates.h | 15 +++++++-------- include/deal.II/lac/vector.templates.h | 19 ++++++++----------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/include/deal.II/lac/la_vector.templates.h b/include/deal.II/lac/la_vector.templates.h index 13b7f298aa..72b0c68019 100644 --- a/include/deal.II/lac/la_vector.templates.h +++ b/include/deal.II/lac/la_vector.templates.h @@ -592,15 +592,14 @@ namespace LinearAlgebra // Other version of the following // out << size() << std::endl << '['; - // Reason: operator<< seems to use some resources that lead to problems in - // a multithreaded environment. - const size_type sz = this->size(); - char buf[16]; -#ifdef DEAL_II_WITH_64BIT_INDICES + // Reason: operator<< seems to use some resources that lead to problems in + // a multithreaded environment. We convert the size index to + // unsigned long long int that is at least 64 bits to be able to output it + // on all platforms, since std::uint64_t is not in C. + const unsigned long long int sz = this->size(); + char buf[16]; + std::sprintf(buf, "%llu", sz); -#else - std::sprintf(buf, "%u", sz); -#endif std::strcat(buf, "\n["); out.write(buf, std::strlen(buf)); diff --git a/include/deal.II/lac/vector.templates.h b/include/deal.II/lac/vector.templates.h index a2917edb74..4227388e60 100644 --- a/include/deal.II/lac/vector.templates.h +++ b/include/deal.II/lac/vector.templates.h @@ -920,18 +920,15 @@ Vector::block_write(std::ostream &out) const // other version of the following // out << size() << std::endl << '['; - // reason: operator<< seems to use - // some resources that lead to - // problems in a multithreaded - // environment - const size_type sz = size(); - char buf[16]; - -#ifdef DEAL_II_WITH_64BIT_INDICES + + // reason: operator<< seems to use some resources that lead to problems in a + // multithreaded environment. We convert the size index to + // unsigned long long int that is at least 64 bits to be able to output it on + // all platforms, since std::uint64_t is not in C. + const unsigned long long int sz = size(); + char buf[16]; + std::sprintf(buf, "%llu", sz); -#else - std::sprintf(buf, "%u", sz); -#endif std::strcat(buf, "\n["); out.write(buf, std::strlen(buf)); -- 2.39.5