]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix two 64 bit warnings by converting to long long unsigned 9591/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 2 Mar 2020 14:12:05 +0000 (15:12 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 2 Mar 2020 14:48:42 +0000 (15:48 +0100)
include/deal.II/lac/la_vector.templates.h
include/deal.II/lac/vector.templates.h

index 13b7f298aafbb9a6edd0a46f78091ea4c47c5faf..72b0c68019846edc515d7d9d24f1c245c55d0bfc 100644 (file)
@@ -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));
index a2917edb748b91de9abef8ecb9ed92ebef9a0c7c..4227388e607ed9f38ab6d41ef49dfd9b38d529b9 100644 (file)
@@ -920,18 +920,15 @@ Vector<Number>::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));

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.