libflame icon indicating copy to clipboard operation
libflame copied to clipboard

Macros with general names in Flame.h break compilation

Open stefanozampini opened this issue 3 years ago • 0 comments

With a configuration like ./configure --enable-arg-max-hack --enable-lapack2flame we currently get a lot of non-namespaced defines when including Flame.h in a source code

Specifically, the min define breaks compilation with GCC 10.2

 /sw/csi/gcc/10.2.0/include/c++/10.2.0/bits/istream.tcc: In member function ‘std::streamsize std::basic_istream<_CharT, _Traits>::readsome(std::basic_istream<_CharT, _Traits>::char_type*, std::streamsize)’:
/home/zampins/amd/src/local/include/FLAME.h:830:21: error: expected unqualified-id before ‘(’ token
  830 | #define min( x, y ) ( (x) < (y) ? (x) : (y) )

Here is a list of the most interesting ones. Is it possible to namespace them?

#undef  NULL
#define NULL 0

#undef  TRUE
#undef  FALSE
#define TRUE  1
#define FALSE 0

#undef min
#define min( x, y ) ( (x) < (y) ? (x) : (y) )

#undef max
#define max( x, y ) ( (x) > (y) ? (x) : (y) )

#undef signof
#define signof( a, b ) ( (b) >= 0 ? (a) : -(a) )

#undef exchange
#define exchange( a, b, temp ) { temp = a; a = b; b = temp; }
#define TRUE_ (1)
#define FALSE_ (0)

#ifndef f2c_abs
  #define f2c_abs(x) ((x) >= 0 ? (x) : -(x))
#endif
#ifndef f2c_dabs
  #define f2c_dabs(x) (doublereal)f2c_abs(x)
#endif
#ifndef min
  #define min(a,b) ((a) <= (b) ? (a) : (b))
#endif
#ifndef max
  #define max(a,b) ((a) >= (b) ? (a) : (b))
#endif
#ifndef dmin
  #define dmin(a,b) (doublereal)min(a,b)
#endif
#ifndef dmax
  #define dmax(a,b) (doublereal)max(a,b)
#endif

stefanozampini avatar May 05 '21 13:05 stefanozampini