pgbackrest.git / summary / log / commit / refs
commit 91bbe810592c8b57079230d0bf15720d74c705fa
Author: David Steele <david@pgmasters.net>
Date: Fri Apr 22 13:14:12 2022 +0000
Add SIZE_OF_STRUCT_MEMBER() macro.
Gets the size of a struct member, which requires a bit of additional syntax.
src/common/macro.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/common/macro.h b/src/common/macro.h
index 8b94686c8..8090998b9 100644
--- a/src/common/macro.h
+++ b/src/common/macro.h
@@ -99,6 +99,13 @@ This is useful for determining how to correctly align a type in a buffer that is
***********************************************************************************************************************************/
#define ALIGN_OFFSET(type, bytes) (ALIGN_OF(type) - ((bytes) % ALIGN_OF(type)))
+/***********************************************************************************************************************************
+Determine size of a type in a struct
+
+Using sizeof() on a struct member requires additional syntax.
+***********************************************************************************************************************************/
+#define SIZE_OF_STRUCT_MEMBER(struct, member) sizeof(((struct){0}).member)
+
/***********************************************************************************************************************************
Determine the length of an array that can be determined at compile time
[parent: a2eee156b5a8]