[ET Trac] [Einstein Toolkit] #1374: C++ complex implementation fails to compile

Einstein Toolkit trac-noreply at einsteintoolkit.org
Thu May 30 20:05:38 CDT 2013


#1374: C++ complex implementation fails to compile
----------------------+-----------------------------------------------------
 Reporter:  knarf     |       Owner:                     
     Type:  defect    |      Status:  new                
 Priority:  critical  |   Milestone:  ET_2013_05         
Component:  Cactus    |     Version:  development version
 Keywords:            |  
----------------------+-----------------------------------------------------
 When compiling I get:
 {{{
 COMPILING
 /home/knarf/Cactus/arrangements/CactusCoastal/Funwave/src/declare.cc
 In file included from /usr/include/c++/4.7/complex:46:0,
                  from /home/knarf/Cactus/src/include/cctk_Types.h:40,
                  from /home/knarf/Cactus/src/include/cctk_Groups.h:34,
                  from
 /home/knarf/Cactus/arrangements/CactusCoastal/Funwave/src/cctk_declare.h:9,
                  from
 /home/knarf/Cactus/configs/sim/build/Funwave/declare.cc:1:
 /usr/include/c++/4.7/cmath: In function ‘constexpr float std::abs(float)’:
 /usr/include/c++/4.7/cmath:90:16: error: declaration of C function
 ‘constexpr float std::abs(float)’ conflicts with
 /usr/include/c++/4.7/cmath:84:3: error: previous declaration ‘constexpr
 double std::abs(double)’ here
 /usr/include/c++/4.7/cmath: In function ‘constexpr long double
 std::abs(long double)’:
 /usr/include/c++/4.7/cmath:94:22: error: declaration of C function
 ‘constexpr long double std::abs(long double)’ conflicts with
 /usr/include/c++/4.7/cmath:90:3: error: previous declaration ‘constexpr
 float std::abs(float)’ here
 /usr/include/c++/4.7/cmath:94:22: error: declaration of C function
 ‘constexpr long double std::abs(long double)’ conflicts with
 /usr/include/c++/4.7/cmath:84:3: error: previous declaration ‘constexpr
 double std::abs(double)’ here
 /usr/include/c++/4.7/cmath: At global scope:
 /usr/include/c++/4.7/cmath:98:3: error: template with C linkage
 }}}

 This seems to be caused by cctk_Groups.h going into "C" linkage, then
 including cctk_Types.h which includes <complex> when compiled with C++.
 The system complex implementation however (at least in CXX0X mode) uses
 templates, which aren't allowed with "C" linkage.

 I use gnu g++ version 4.7 with -std=gnu++0x.

 Applying the following patch to src/include/cctk_Types.h solves the
 problem for me:
 {{{
 Index: cctk_Types.h
 ===================================================================
 --- cctk_Types.h        (revision 5021)
 +++ cctk_Types.h        (working copy)
 @@ -37,7 +37,9 @@
  /* Declarations for complex types */

  #ifdef __cplusplus
 +extern "C++" {
  #  include <complex>
 +}
  #endif

  #ifdef HAVE_CCTK_REAL16
 }}}

-- 
Ticket URL: <https://trac.einsteintoolkit.org/ticket/1374>
Einstein Toolkit <http://einsteintoolkit.org>
The Einstein Toolkit


More information about the Trac mailing list