From e1942bb490cabcc40cd8fdd3fe042c3427c72619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sun, 9 Feb 2014 14:43:20 -0800 Subject: [PATCH] Added BX_ENABLED macro. --- include/bx/bx.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/include/bx/bx.h b/include/bx/bx.h index c666777..2f3c062 100644 --- a/include/bx/bx.h +++ b/include/bx/bx.h @@ -16,7 +16,21 @@ namespace bx { // http://cnicholson.net/2011/01/stupid-c-tricks-a-better-sizeof_array/ template char (&COUNTOF_REQUIRES_ARRAY_ARGUMENT(const T(&)[N]) )[N]; -#define BX_COUNTOF(x) sizeof(bx::COUNTOF_REQUIRES_ARRAY_ARGUMENT(x) ) +#define BX_COUNTOF(_x) sizeof(bx::COUNTOF_REQUIRES_ARRAY_ARGUMENT(_x) ) + + // Template for avoiding MSVC: C4127: conditional expression is constant + template + BX_FORCE_INLINE bool isEnabled() + { + return true; + } + + template<> + BX_FORCE_INLINE bool isEnabled() + { + return false; + } +#define BX_ENABLED(_x) bx::isEnabled() } // namespace bx