Skip to content

Commit 8eed3a4

Browse files
[libc] improve macro guards
1 parent 43126f7 commit 8eed3a4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libc/src/__support/macros/attributes.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,29 @@ LIBC_THREAD_MODE_EXTERNAL.
9191
#define LIBC_NO_SANITIZE_OOB_ACCESS
9292
#endif
9393

94-
#if __has_attribute(lifetimebound)
94+
#if __has_cpp_attribute(clang::lifetimebound)
9595
#define LIBC_LIFETIME_BOUND [[clang::lifetimebound]]
96+
#elif __has_cpp_attribute(msvc::lifetimebound)
97+
#define LIBC_LIFETIME_BOUND [[msvc::lifetimebound]]
98+
#elif __has_cpp_attribute(lifetimebound)
99+
#define LIBC_LIFETIME_BOUND [[lifetimebound]]
96100
#else
97101
#define LIBC_LIFETIME_BOUND
98102
#endif
99103

100-
#if __has_attribute(lifetime_capture_by)
104+
#if __has_cpp_attribute(clang::lifetime_capture_by)
101105
#define LIBC_LIFETIME_CAPTURE_BY(X) [[clang::lifetime_capture_by(X)]]
102106
#else
103107
#define LIBC_LIFETIME_CAPTURE_BY(X)
104108
#endif
105109

106-
#if defined(__clang__)
110+
#if __has_cpp_attribute(gsl::Pointer)
107111
#define LIBC_GSL_POINTER [[gsl::Pointer]]
108112
#else
109113
#define LIBC_GSL_POINTER
110114
#endif
111115

112-
#if defined(__clang__)
116+
#if __has_cpp_attribute(gsl::Owner)
113117
#define LIBC_GSL_OWNER [[gsl::Owner]]
114118
#else
115119
#define LIBC_GSL_OWNER

0 commit comments

Comments
 (0)