Tue, 22 Oct 2024 22:42:48 +0200
add cx_nmemb() utility
CHANGELOG | file | annotate | diff | comparison | revisions | |
src/cx/common.h | file | annotate | diff | comparison | revisions |
--- 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
--- 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