From 1d858667d8e9f34a8f88aa77ba8eb671973037c4 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Mon, 18 Sep 2023 20:27:13 -0300 Subject: [PATCH] Replace FB_NELEM macro by constexpr function. --- src/include/fb_types.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/include/fb_types.h b/src/include/fb_types.h index 24ecf03d56..1daeff94a2 100644 --- a/src/include/fb_types.h +++ b/src/include/fb_types.h @@ -32,6 +32,7 @@ #ifndef INCLUDE_FB_TYPES_H #define INCLUDE_FB_TYPES_H +#include #include #if SIZEOF_LONG == 8 @@ -132,8 +133,12 @@ vmslock.cpp:LOCK_convert() calls VMS' sys$enq that may require this signature, but our code never uses the return value. */ typedef int (*lock_ast_t)(void*); -/* Number of elements in an array */ -#define FB_NELEM(x) ((int)(sizeof(x) / sizeof(x[0]))) +// Number of elements in an array +template +constexpr int FB_NELEM(const T (&)[N]) +{ + return N; +} // Intl types typedef SSHORT CHARSET_ID;