From: lottaviano Date: Fri, 27 May 2011 09:17:06 +0000 (+0000) Subject: Fix nightly test warnings in hashtable implementation. X-Git-Tag: 2.7.0~34 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=9fd3c727a7978547a583868f0bf9689d6dffc542;p=bertos.git Fix nightly test warnings in hashtable implementation. The warning is reported with latest versions of GCC, starting from 4.5. The array definition didn't use a constant expression (as defined by the standard). Defining an enum value fixes the issue. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4932 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/struct/hashtable.h b/bertos/struct/hashtable.h index 695be327..07a514d5 100644 --- a/bertos/struct/hashtable.h +++ b/bertos/struct/hashtable.h @@ -133,7 +133,8 @@ typedef struct /** Exactly like \c DECLARE_HASHTABLE, but the variable will be declared as static. */ #define DECLARE_HASHTABLE_STATIC(name, size, hook_gk) \ - static const void* name##_nodes[1 << UINT32_LOG2(size)]; \ + enum { name##_SIZE = (1 << UINT32_LOG2(size)), }; \ + static const void* name##_nodes[name##_SIZE]; \ static struct HashTable name = \ { \ .mem = name##_nodes, \ @@ -155,8 +156,10 @@ typedef struct /** Exactly like \c DECLARE_HASHTABLE_INTERNALKEY, but the variable will be declared as static. */ #define DECLARE_HASHTABLE_INTERNALKEY_STATIC(name, size) \ - static uint8_t name##_keys[(1 << UINT32_LOG2(size)) * (INTERNAL_KEY_MAX_LENGTH + 1)]; \ - static const void* name##_nodes[1 << UINT32_LOG2(size)]; \ + enum { name##_KEYS = ((1 << UINT32_LOG2(size)) * (INTERNAL_KEY_MAX_LENGTH + 1)), \ + name##_SIZE = (1 << UINT32_LOG2(size)), }; \ + static uint8_t name##_keys[name##_KEYS]; \ + static const void* name##_nodes[name##_SIZE]; \ static struct HashTable name = \ { \ .mem = name##_nodes, \