Skip to content

Commit 64652d3

Browse files
authored
improve clang attribute detection
1 parent f8e3b7e commit 64652d3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
- On Linux, setting a long backend thread name now truncates it instead of
198198
failing. ([#691](https://github.com/odygrd/quill/issues/691))
199199
- Fixed BSD builds. ([#688](https://github.com/odygrd/quill/issues/688))
200+
- Fixed `QUILL_ATTRIBUTE_HOT` and `QUILL_ATTRIBUTE_COLD` clang detection
200201
- CMake improvements: switched to range syntax for minimum required version and bumped minimum required CMake version to
201202
`3.12`. ([#686](https://github.com/odygrd/quill/issues/686))
202203
- Correct the installation location of pkg-config files. They are now properly placed in `/usr/local/lib`.

include/quill/core/Attributes.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
* Portable maybe_unused
6868
*/
6969
#ifndef QUILL_MAYBE_UNUSED
70-
#if QUILL_HAS_CPP_ATTRIBUTE(maybe_unused) && (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
70+
#if QUILL_HAS_CPP_ATTRIBUTE(maybe_unused) && (__cplusplus >= 201703L)
7171
#define QUILL_MAYBE_UNUSED [[maybe_unused]]
72-
#elif QUILL_HAS_ATTRIBUTE(__unused__) || defined(__GNUC__)
72+
#elif QUILL_HAS_ATTRIBUTE(__unused__)
7373
#define QUILL_MAYBE_UNUSED __attribute__((__unused__))
7474
#elif defined(_MSC_VER)
7575
#define QUILL_MAYBE_UNUSED __pragma(warning(suppress : 4100))
@@ -85,15 +85,15 @@
8585
* is likely to be not-taken.
8686
*/
8787
#ifndef QUILL_ATTRIBUTE_HOT
88-
#if QUILL_HAS_ATTRIBUTE(hot) || (defined(__GNUC__) && !defined(__clang__))
88+
#if QUILL_HAS_ATTRIBUTE(hot)
8989
#define QUILL_ATTRIBUTE_HOT __attribute__((hot))
9090
#else
9191
#define QUILL_ATTRIBUTE_HOT
9292
#endif
9393
#endif
9494

9595
#ifndef QUILL_ATTRIBUTE_COLD
96-
#if QUILL_HAS_ATTRIBUTE(cold) || (defined(__GNUC__) && !defined(__clang__))
96+
#if QUILL_HAS_ATTRIBUTE(cold)
9797
#define QUILL_ATTRIBUTE_COLD __attribute__((cold))
9898
#else
9999
#define QUILL_ATTRIBUTE_COLD
@@ -104,7 +104,7 @@
104104
* Used
105105
*/
106106
#ifndef QUILL_ATTRIBUTE_USED
107-
#if QUILL_HAS_ATTRIBUTE(used) || defined(__GNUC__) || defined(__clang__)
107+
#if QUILL_HAS_ATTRIBUTE(used)
108108
#define QUILL_ATTRIBUTE_USED __attribute__((used))
109109
#else
110110
#define QUILL_ATTRIBUTE_USED

0 commit comments

Comments
 (0)