]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Do not use I in header files due to conflict with <complex.h> 7700/head
authorBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 6 Feb 2019 22:00:24 +0000 (17:00 -0500)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 6 Feb 2019 22:00:24 +0000 (17:00 -0500)
The C version of <complex.h> defines the macro I. So when a third-party
library such as lapacke include <complex.h> is included before the
header the variable I is expanded which trips the compiler.

include/deal.II/base/patterns.h
include/deal.II/physics/transformations.h

index d4ea6babc0b2258652920e4bdc1fa20a008bdde8..3a8617fc91e00dd4ce9a28c3471f45f1061f3fa2 100644 (file)
@@ -2296,15 +2296,15 @@ namespace Patterns
       }
 
     private:
-      template <std::size_t... I>
+      template <std::size_t... U>
       static std::array<std::string, std::tuple_size<T>::value>
       to_string_internal_1(const T &              t,
                            const Patterns::Tuple &pattern,
-                           std_cxx14::index_sequence<I...>)
+                           std_cxx14::index_sequence<U...>)
       {
         std::array<std::string, std::tuple_size<T>::value> a = {
-          {Convert<typename std::tuple_element<I, T>::type>::to_string(
-            std::get<I>(t), pattern.get_pattern(I).clone())...}};
+          {Convert<typename std::tuple_element<U, T>::type>::to_string(
+            std::get<U>(t), pattern.get_pattern(U).clone())...}};
         return a;
       }
 
@@ -2317,15 +2317,15 @@ namespace Patterns
           std_cxx14::make_index_sequence<std::tuple_size<T>::value>{});
       }
 
-      template <std::size_t... I>
+      template <std::size_t... U>
       static T
       to_value_internal_1(const std::vector<std::string> &s,
                           const Patterns::Tuple &         pattern,
-                          std_cxx14::index_sequence<I...>)
+                          std_cxx14::index_sequence<U...>)
       {
         return std::make_tuple(
-          Convert<typename std::tuple_element<I, T>::type>::to_value(
-            s[I], pattern.get_pattern(I).clone())...);
+          Convert<typename std::tuple_element<U, T>::type>::to_value(
+            s[U], pattern.get_pattern(U).clone())...);
       }
 
       static T
index 322aa29747faa70d54abeed29998cb39501f6eb1..12e8fcc8a32857845aabb8e7fb1fcf71f26e2a49 100644 (file)
@@ -852,8 +852,9 @@ namespace internal
       Tensor<2, dim, Number> tmp_1;
       for (unsigned int i = 0; i < dim; ++i)
         for (unsigned int J = 0; J < dim; ++J)
-          for (unsigned int I = 0; I < dim; ++I)
-            tmp_1[i][J] += F[i][I] * T[I][J];
+          // Loop over I but complex.h defines a macro I, so use I_ instead
+          for (unsigned int I_ = 0; I_ < dim; ++I_)
+            tmp_1[i][J] += F[i][I_] * T[I_][J];
 
       dealii::SymmetricTensor<2, dim, Number> out;
       for (unsigned int i = 0; i < dim; ++i)
@@ -918,12 +919,13 @@ namespace internal
 
       // Push forward (inner) index 1
       Tensor<4, dim, Number> tmp;
-      for (unsigned int I = 0; I < dim; ++I)
+      // Loop over I but complex.h defines a macro I, so use I_ instead
+      for (unsigned int I_ = 0; I_ < dim; ++I_)
         for (unsigned int j = 0; j < dim; ++j)
           for (unsigned int K = 0; K < dim; ++K)
             for (unsigned int L = 0; L < dim; ++L)
               for (unsigned int J = 0; J < dim; ++J)
-                tmp[I][j][K][L] += F[j][J] * H[I][J][K][L];
+                tmp[I_][j][K][L] += F[j][J] * H[I_][J][K][L];
 
       // Push forward (outer) indices 0 and 3
       tmp = contract<1, 0>(F, contract<3, 1>(tmp, F));

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.