Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc617aea

Browse files
committed
Add pg_nodiscard function declaration specifier
pg_nodiscard means the compiler should warn if the result of afunction call is ignored. The name "nodiscard" is chosen in alignmentwith (possibly future) C and C++ standards. It maps to the GCCattribute warn_unused_result.Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://www.postgresql.org/message-id/flat/e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com
1 parentc77f6f5 commitc617aea

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎src/include/c.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@
111111
#definepg_attribute_unused()
112112
#endif
113113

114+
/*
115+
* pg_nodiscard means the compiler should warn if the result of a function
116+
* call is ignored. The name "nodiscard" is chosen in alignment with
117+
* (possibly future) C and C++ standards. For maximum compatibility, use it
118+
* as a function declaration specifier, so it goes before the return type.
119+
*/
120+
#ifdef__GNUC__
121+
#definepg_nodiscard __attribute__((warn_unused_result))
122+
#else
123+
#definepg_nodiscard
124+
#endif
125+
114126
/*
115127
* Append PG_USED_FOR_ASSERTS_ONLY to definitions of variables that are only
116128
* used in assert-enabled builds, to avoid compiler warnings about unused

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp