diff options
author | Ayrton Munoz <ayrton@google.com> | 2022-10-15 00:53:07 -0400 |
---|---|---|
committer | Ayrton Munoz <ayrton@google.com> | 2022-10-17 22:17:38 -0400 |
commit | 4ddd4c1b4914daba9e9b7ae32d448cf706110d09 (patch) | |
tree | f4e746b7f591aa64b3254a84f33a7fa70d0e88b2 /hosttests | |
parent | 6112644219b18170dbe9d0ca2ef4c38ef549b0d6 (diff) | |
download | common-4ddd4c1b4914daba9e9b7ae32d448cf706110d09.tar.gz |
include/compiler.h: Replace countof macro with inline function in C++
libcxx's locale.cpp defines an internal countof function so
this commit replaces that macro with an inline function
definition whenever compiler.h is included in C++. It also
adds the countof macro in two host tests that call countof
on pointers to empty arrays since zero-sized arrays are not
permitted in C++.
Bug: 230134581
Change-Id: I4d8dc311f86a1e6df5231ca4a16587023becca58
Diffstat (limited to 'hosttests')
-rw-r--r-- | hosttests/listtest/list_test.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/hosttests/listtest/list_test.cpp b/hosttests/listtest/list_test.cpp index acec88b8..a0f80c54 100644 --- a/hosttests/listtest/list_test.cpp +++ b/hosttests/listtest/list_test.cpp @@ -63,13 +63,15 @@ static void CheckListArray(struct list_node *list, struct list_node *items[], EXPECT_EQ(i, count) << "List has fewer items than expected"; } +#define ArraySize(a) (sizeof(a) / sizeof((a)[0])) + /** * CheckList - Helper macro to call CheckListArray. */ #define CheckList(list, items...) { \ SCOPED_TRACE("CheckList"); \ struct list_node *itemarray[] = {items}; \ - CheckListArray(list, itemarray, countof(itemarray)); \ + CheckListArray(list, itemarray, ArraySize(itemarray)); \ } /** |