# HG changeset patch # User Mike Becker # Date 1729629768 -7200 # Node ID 84a5fab8a47c468fec80e18cc43593c78f783a5c # Parent c26299cc9897f460c9b3c98d9a67ab574be2f308 add cx_nmemb() utility diff -r c26299cc9897 -r 84a5fab8a47c CHANGELOG --- a/CHANGELOG Tue Oct 22 22:20:50 2024 +0200 +++ b/CHANGELOG Tue Oct 22 22:42:48 2024 +0200 @@ -10,6 +10,7 @@ * adds cx_sprintf() and several more variants * adds runtime constants to read out the actual SBO sizes * adds improved version of UCX 2 Test framework (now a self-contained header) + * adds cx_nmemb() utility function to common.h * the cx_compare_func symbol is now declared by compare.h * fixes wrong link from UCX 2 documentation to UCX 3 documentation * fixes critical bug that produced wrong results when comparing lists of different type but same size diff -r c26299cc9897 -r 84a5fab8a47c src/cx/common.h --- a/src/cx/common.h Tue Oct 22 22:20:50 2024 +0200 +++ b/src/cx/common.h Tue Oct 22 22:42:48 2024 +0200 @@ -117,6 +117,16 @@ void * ); +/** + * Determines the number of members in a static C array. + * + * @attention never use this to determine the size of a dynamically allocated + * array. + * + * @param arr the array identifier + * @return the number of elements + */ +#define cx_nmemb(arr) (sizeof(arr)/sizeof((arr)[0])) // Compiler specific stuff