Karl Rupp  committed 8ab1f23 Merge

Merge branch 'karlrupp/fix-restrict-keyword' into next

  • Participants
  • Parent commits 193eec4, fda6662
  • Branches jed/next-seaice, knepley/fix-quadrature-order 3
    1. madams/sr-driver
    2. madams/sr1
    3. next-oct-2014

Comments (0)

Files changed (2)

File config/BuildSystem/config/

         if line: f.write('/* '+line+' */\n')
     f.write('#ifndef '+guard+'\n')
     if value:
-      f.write('#define '+name+' '+str(value)+'\n')
+      # Magic token in order to split a define into two pieces: One for C++, the other for C.
+      # Blame Karl Rupp for this hack, who couldn't find a better solution without rewriting larger parts of BuildSystem
+      if '[C/CXX-SPLIT]' in str(value):
+        f.write('#if defined(__cplusplus)\n')
+        f.write('#define '+name+' '+str(value).split('[C/CXX-SPLIT]')[1]+'\n')
+        f.write('#else\n')
+        f.write('#define '+name+' '+str(value).split('[C/CXX-SPLIT]')[0]+'\n')
+        f.write('#endif\n')
+      else:
+        f.write('#define '+name+' '+str(value)+'\n')
       f.write('/* #undef '+name+' */\n')

File config/PETSc/

     '''Get a generic inline keyword, depending on the language'''
     if self.languages.clanguage == 'C':
       self.addDefine('STATIC_INLINE', self.compilers.cStaticInlineKeyword)
-      self.addDefine('RESTRICT', self.compilers.cRestrict)
     elif self.languages.clanguage == 'Cxx':
       self.addDefine('STATIC_INLINE', self.compilers.cxxStaticInlineKeyword)
-      self.addDefine('RESTRICT', self.compilers.cxxRestrict)
+    self.addDefine('RESTRICT', self.compilers.cRestrict + '[C/CXX-SPLIT]' + self.compilers.cxxRestrict)
     if self.checkCompile('#include <dlfcn.h>\n void *ptr =  RTLD_DEFAULT;'):