From 7514a663506af67f9aeab84e60428d81c942addc Mon Sep 17 00:00:00 2001 From: Tom Schouten Date: Thu, 1 Nov 2012 23:47:27 +0000 Subject: creb: proper ifdefs for __COUNTER__ macro svn path=/trunk/externals/creb/; revision=16514 --- modules/extlib_util.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'modules/extlib_util.h') diff --git a/modules/extlib_util.h b/modules/extlib_util.h index b1ceff1..50b0c20 100644 --- a/modules/extlib_util.h +++ b/modules/extlib_util.h @@ -23,14 +23,19 @@ #include #include "m_pd.h" -/* Compile-time asserts. */ -/* On OSX it seems that _GENSYM(_ctassert_) expands to - '_ctassert___COUNTER__ i.e. the __COUNTER__ built-in symbol is not - expanded before it is concatenated. As a workaround it is disabled - on OSX. This seems OK since CT_ASSERTs serve their purpose in the - Linux build. */ -#ifdef __APPLE__ -#define CT_ASSERT(x) +// __COUNTER__ is a CPP extension enabled in gcc >= 4.3 +#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ >= 3 +#define HAVE_COUNTER +#endif +#if defined __GNUC__ && __GNUC__ >= 5 +#define HAVE_COUNTER +#endif +#ifdef __clang__ // Should we check version here? +#define HAVE_COUNTER +#endif +#ifndef HAVE_COUNTER +#warning CT_ASSERT() disabled +#define CT_ASSERT(...) #else #define CT_NAMED_ASSERT(name,x) \ typedef int _GENSYM(name ## _ctassert_)[-((x)==0)] -- cgit v1.2.1