mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-29 00:03:58 +01:00
17 lines
660 B
C
17 lines
660 B
C
#pragma once
|
|
|
|
#include <assert.h>
|
|
|
|
#ifdef __has_builtin
|
|
#if !__cplusplus && FF_SUPPORTS_COUNT_OF
|
|
#define ARRAY_SIZE(x) _Countof(x)
|
|
#elif __has_builtin(__is_array)
|
|
#define ARRAY_SIZE(x) ({ static_assert(__is_array(__typeof__(x)), "Must be an array"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
|
#elif __has_builtin(__builtin_types_compatible_p)
|
|
#define ARRAY_SIZE(x) ({ static_assert(!__builtin_types_compatible_p(__typeof__(x), __typeof__(&*(x))), "Must not be a pointer"); (uint32_t) (sizeof(x) / sizeof(*(x))); })
|
|
#endif
|
|
#endif
|
|
#ifndef ARRAY_SIZE
|
|
#define ARRAY_SIZE(x) ((uint32_t) (sizeof(x) / sizeof(*(x))))
|
|
#endif
|