commit 53801880d81d72cad50fda1afaa265e8a869c9d1
parent 216c376241c30cdf4910fedad74baae0e06dfba6
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date: Thu, 3 Mar 2022 09:23:32 +0100
Add CLAP_NODISCARD
Diffstat:
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/clap/private/macros.h b/include/clap/private/macros.h
@@ -20,3 +20,11 @@
#else
# define CLAP_CONSTEXPR
#endif
+
+#if defined(__cplusplus) && __cplusplus >= 201703L
+# define CLAP_NODISCARD [[nodiscard]]
+#elsif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201300L
+# define CLAP_NODISCARD [[nodiscard]]
+#else
+# define CLAP_NODISCARD
+#endif
diff --git a/include/clap/stream.h b/include/clap/stream.h
@@ -1,6 +1,7 @@
#pragma once
#include "private/std.h"
+#include "private/macros.h"
#ifdef __cplusplus
extern "C" {
@@ -12,7 +13,7 @@ typedef struct clap_istream {
/* returns the number of bytes read.
* 0 for end of file.
* -1 on error. */
- int64_t (*read)(struct clap_istream *stream, void *buffer, uint64_t size);
+ CLAP_NODISCARD int64_t (*read)(struct clap_istream *stream, void *buffer, uint64_t size);
} clap_istream_t;
typedef struct clap_ostream {
@@ -20,7 +21,7 @@ typedef struct clap_ostream {
/* returns the number of bytes written.
* -1 on error. */
- int64_t (*write)(struct clap_ostream *stream, const void *buffer, uint64_t size);
+ CLAP_NODISCARD int64_t (*write)(struct clap_ostream *stream, const void *buffer, uint64_t size);
} clap_ostream_t;
#ifdef __cplusplus