diff options
-rw-r--r-- | src/include/c.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/include/c.h b/src/include/c.h index 9cd67f8f765..d5dc3632f74 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -112,6 +112,18 @@ #endif /* + * pg_nodiscard means the compiler should warn if the result of a function + * call is ignored. The name "nodiscard" is chosen in alignment with + * (possibly future) C and C++ standards. For maximum compatibility, use it + * as a function declaration specifier, so it goes before the return type. + */ +#ifdef __GNUC__ +#define pg_nodiscard __attribute__((warn_unused_result)) +#else +#define pg_nodiscard +#endif + +/* * Append PG_USED_FOR_ASSERTS_ONLY to definitions of variables that are only * used in assert-enabled builds, to avoid compiler warnings about unused * variables in assert-disabled builds. |