From: Martin Kronbichler Date: Mon, 2 Mar 2020 14:12:05 +0000 (+0100) Subject: Fix two 64 bit warnings by converting to long long unsigned X-Git-Tag: v9.2.0-rc1~480^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0041bfc41bd06f4e039854240efe2db23cd4d0bb;p=dealii.git Fix two 64 bit warnings by converting to long long unsigned --- 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));