X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fmacros.h;fp=src%2Fcommon%2Fmacros.h;h=e9dc190aac3f00c0235d272d375c950632013a26;hp=97faf03280925fc3503a9ddb6d348093c07c1501;hb=0d79f53ed591cb2e314d2db51c62f3900a956fa3;hpb=c30417c11fcaf0406c4cfb3a09373c848a86e291 diff --git a/src/common/macros.h b/src/common/macros.h index 97faf0328..e9dc190aa 100644 --- a/src/common/macros.h +++ b/src/common/macros.h @@ -57,20 +57,30 @@ void *zmalloc(size_t len) }) #endif -#ifndef max -#define max(a, b) ((a) > (b) ? (a) : (b)) -#endif -#ifndef max_t -#define max_t(type, a, b) max((type) a, (type) b) -#endif +/* + * The min and max macros are not needed in C++ (std::min and std::max are + * preferred) and they conflict with some C++ header file. Don't define them + * when compiling C++ source. + */ +#ifndef __cplusplus -#ifndef min -#define min(a, b) ((a) < (b) ? (a) : (b)) -#endif +# ifndef max +# define max(a, b) ((a) > (b) ? (a) : (b)) +# endif + +# ifndef min +# define min(a, b) ((a) < (b) ? (a) : (b)) +# endif + +# ifndef max_t +# define max_t(type, a, b) max((type) a, (type) b) +# endif + +# ifndef min_t +# define min_t(type, a, b) min((type) a, (type) b) +# endif -#ifndef min_t -#define min_t(type, a, b) min((type) a, (type) b) #endif #ifndef LTTNG_PACKED