Skip to content

Commit 81b1753

Browse files
authored
Fix compilation error for old version of GCC (#48)
1 parent e9b2b10 commit 81b1753

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

ddcommon-ffi/cbindgen.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,23 @@ after_includes = """
2222
/* NOTE: Compilation fails if you pass in a char* instead of a literal */ ((ddog_CharSlice){ .ptr = "" string, .len = sizeof(string) - 1 })
2323
#endif
2424
25+
#if defined __GNUC__
26+
# define DDOG_GNUC_VERSION(major) __GNUC__ >= major
27+
#else
28+
# define DDOG_GNUC_VERSION(major) (0)
29+
#endif
30+
31+
#if defined __has_attribute
32+
# define DDOG_HAS_ATTRIBUTE(attribute, major) __has_attribute(attribute)
33+
#else
34+
# define DDOG_HAS_ATTRIBUTE(attribute, major) DDOG_GNUC_VERSION(major)
35+
#endif
36+
2537
#if defined(__cplusplus) && (__cplusplus >= 201703L)
2638
# define DDOG_CHECK_RETURN [[nodiscard]]
2739
#elif defined(_Check_return_) /* SAL */
2840
# define DDOG_CHECK_RETURN _Check_return_
29-
#elif (defined(__has_attribute) && __has_attribute(warn_unused_result)) || \\
30-
(defined(__GNUC__) && (__GNUC__ >= 4))
41+
#elif DDOG_HAS_ATTRIBUTE(warn_unused_result, 4)
3142
# define DDOG_CHECK_RETURN __attribute__((__warn_unused_result__))
3243
#else
3344
# define DDOG_CHECK_RETURN

0 commit comments

Comments
 (0)