aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-08-09 16:15:23 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-08-09 16:15:23 +0300
commit8d5086f052f4282f22d350ac44f6699f3bdf7a06 (patch)
tree9674b8b6fc77fbdb82a9013653efa5d2aa63bd0b
parent1aa61f108a1cb1b24219bf0fc0dc52f72c310e89 (diff)
Declare warn_unused_result only on GCC >= 3.4.0.
Thanks to cea.max.simoes for bug report & fix. Update issue 25 Status: FixedInGit
-rw-r--r--pb_decode.c10
-rw-r--r--pb_encode.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/pb_decode.c b/pb_decode.c
index 6d3a0b6c..5ef40ecc 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -3,12 +3,12 @@
* 2011 Petteri Aimonen <jpa@kapsi.fi>
*/
-
-#ifdef __GNUC__
-/* Verify that we remember to check all return values for proper error propagation */
-#define checkreturn __attribute__((warn_unused_result))
+/* The warn_unused_result attribute appeared first in gcc-3.4.0 */
+#if !defined(__GNUC__) || ( __GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
+ #define checkreturn
#else
-#define checkreturn
+ /* Verify that we remember to check all return values for proper error propagation */
+ #define checkreturn __attribute__((warn_unused_result))
#endif
#include "pb.h"
diff --git a/pb_encode.c b/pb_encode.c
index 8868bb64..3fc03811 100644
--- a/pb_encode.c
+++ b/pb_encode.c
@@ -8,14 +8,14 @@
#include "pb_encode.h"
#include <string.h>
-#ifdef __GNUC__
-/* Verify that we remember to check all return values for proper error propagation */
-#define checkreturn __attribute__((warn_unused_result))
+/* The warn_unused_result attribute appeared first in gcc-3.4.0 */
+#if !defined(__GNUC__) || ( __GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
+ #define checkreturn
#else
-#define checkreturn
+ /* Verify that we remember to check all return values for proper error propagation */
+ #define checkreturn __attribute__((warn_unused_result))
#endif
-
typedef bool (*pb_encoder_t)(pb_ostream_t *stream, const pb_field_t *field, const void *src) checkreturn;
/* --- Function pointers to field encoders ---