Skip to content

Commit f7a28df

Browse files
committed
Fixup RBS_ATTRIBUTE_UNUSED macro
1 parent da5f922 commit f7a28df

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

include/rbs/defines.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,13 @@
7474
#define NODISCARD __attribute__((warn_unused_result))
7575
#endif
7676

77+
/**
78+
* Mark a function or variable as potentially unused to suppress compiler warnings.
79+
*/
80+
#if defined(__GNUC__) || defined(__clang__)
81+
#define RBS_ATTRIBUTE_UNUSED __attribute__((unused))
82+
#else
83+
#define RBS_ATTRIBUTE_UNUSED
84+
#endif
85+
7786
#endif

include/rbs/util/rbs_encoding.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#ifndef RBS_RBS_ENCODING_H
77
#define RBS_RBS_ENCODING_H
88

9+
#include "rbs/defines.h"
10+
911
#include <assert.h>
1012
#include <stdbool.h>
1113
#include <stddef.h>

src/util/rbs_constant_pool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ next_power_of_two(uint32_t v) {
3737
return v;
3838
}
3939

40-
__attribute__((unused)) static bool is_power_of_two(uint32_t size) {
40+
RBS_ATTRIBUTE_UNUSED static bool is_power_of_two(uint32_t size) {
4141
return (size & (size - 1)) == 0;
4242
}
4343

src/util/rbs_encoding.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33

44
#include <ctype.h>
55

6-
#if defined(__GNUC__)
7-
#define RBS_ATTRIBUTE_UNUSED __attribute__((unused))
8-
#else
9-
#define RBS_ATTRIBUTE_UNUSED
10-
#endif
11-
126
typedef uint32_t rbs_unicode_codepoint_t;
137

148
#define UNICODE_ALPHA_CODEPOINTS_LENGTH 1450

0 commit comments

Comments
 (0)