diff --git a/cluster_library.h b/cluster_library.h index 731ec03..361a1e5 100644 --- a/cluster_library.h +++ b/cluster_library.h @@ -378,7 +378,7 @@ PHP_REDIS_API redisCluster *cluster_create(double timeout, double read_timeout, int failover, int persistent); PHP_REDIS_API void cluster_free(redisCluster *c, int free_ctx); PHP_REDIS_API void cluster_init_seeds(redisCluster *c, zend_string **seeds, uint32_t nseeds); -PHP_REDIS_API int cluster_map_keyspace(redisCluster *c); +REDIS_NODISCARD PHP_REDIS_API int cluster_map_keyspace(redisCluster *c); PHP_REDIS_API void cluster_free_node(redisClusterNode *node); /* Functions for interacting with cached slots maps */ diff --git a/common.h b/common.h index 559e4a2..8936c8e 100644 --- a/common.h +++ b/common.h @@ -41,6 +41,31 @@ # error "Unknown endianness" #endif +#if defined(_MSC_VER) && !defined(__clang__) +# define REDIS_MSVC 1 +#endif + +#ifndef REDIS_MSVC +# if defined(__has_c_attribute) +# if __has_c_attribute(nodiscard) +# define REDIS_NODISCARD [[nodiscard]] +# endif +# endif +# ifndef REDIS_NODISCARD +# if defined(__has_attribute) +# if __has_attribute(warn_unused_result) +# define REDIS_NODISCARD __attribute__((warn_unused_result)) +# endif +# elif defined(__GNUC__) || defined(__clang__) +# define REDIS_NODISCARD __attribute__((warn_unused_result)) +# else +# define REDIS_NODISCARD +# endif +# endif +#else +# define REDIS_NODISCARD +#endif + #include "backoff.h" typedef enum {