From 47d46418dff91a1465e95517022abc84607a4da7 Mon Sep 17 00:00:00 2001 From: arighi Date: Fri, 24 Sep 2010 13:00:47 +0000 Subject: [PATCH] countof(): use STATIC_ASSERT_EXPR() to perform compile-time type checking git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4296 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cfg/compiler.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bertos/cfg/compiler.h b/bertos/cfg/compiler.h index 8c217c00..843af838 100644 --- a/bertos/cfg/compiler.h +++ b/bertos/cfg/compiler.h @@ -540,10 +540,10 @@ typedef unsigned char sigmask_t; /**< Type for signal masks. */ * NOTE: the construct __builtin_types_compatible_p() is only * available for C. */ - #define countof(a) (sizeof(a) / sizeof(*(a)) + \ - sizeof(typeof(int[1 - 2 * \ - !!__builtin_types_compatible_p(typeof(a), \ - typeof(&a[0]))])) * 0) + #define countof(a) (sizeof(a) / sizeof(*(a)) + \ + STATIC_ASSERT_EXPR( \ + !__builtin_types_compatible_p( \ + typeof(a), typeof(&a[0])))) #else #define countof(a) (sizeof(a) / sizeof(*(a))) #endif -- 2.25.1