summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-07-21 10:56:37 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-07-21 10:56:37 +0100
commit4f6b6da8e99c7ad0d37952e93b76d208ac513891 (patch)
tree7633231ad57d98dcf182c7cb78853fe9bdf7a449
parenta6ba297abbe0a78954de2b2cbd911df899dc985c (diff)
add a _attribute__((warn_unused_result)) based macro
-rw-r--r--sal/inc/sal/types.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/sal/inc/sal/types.h b/sal/inc/sal/types.h
index 1266c9ba7..c1922ea99 100644
--- a/sal/inc/sal/types.h
+++ b/sal/inc/sal/types.h
@@ -296,6 +296,18 @@ typedef void * sal_Handle;
#define SAL_EXCEPTION_DLLPRIVATE
#endif
+/** Use this as markup for functions and methods whose return value must be
+ checked.
+
+ Compilers that support a construct of this nature will emit a compile
+ time warning on unchecked return value.
+*/
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# define SAL_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#else
+# define SAL_WARN_UNUSED_RESULT
+#endif
+
/** Use this for pure virtual classes, e.g. class SAL_NO_VTABLE Foo { ...
This hinders the compiler from setting a generic vtable stating that
a pure virtual function was called and thus slightly reduces code size.