Skip to content

Commit 633b4ba

Browse files
committed
fix: suppress warning of redefined C++ keyword
Suppresses the diagnostic for clang but adds an explainatory comment why this is needed.
1 parent 3773738 commit 633b4ba

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/linux/btop_collect.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,23 @@ tab-size = 4
5757
#include "../btop_tools.hpp"
5858

5959
#if defined(GPU_SUPPORT)
60+
// Redefining C++ keywords fortunately has a warning in clang, however it's unavoidable here
61+
// since the C library uses "class" as a struct member and keywords are not allowed to be used
62+
// as identifiers in C++.
63+
#if defined(__clang__)
64+
#pragma clang diagnostic push
65+
#pragma clang diagnostic ignored "-Wkeyword-macro"
66+
#endif // __clang__
67+
6068
#define class class_
6169
extern "C" {
62-
#include "./intel_gpu_top/intel_gpu_top.h"
70+
#include "intel_gpu_top/intel_gpu_top.h"
6371
}
6472
#undef class
73+
74+
#if defined(__clang__)
75+
#pragma clang diagnostic pop
76+
#endif // __clang__
6577
#endif
6678

6779
using std::abs;

0 commit comments

Comments
 (0)