git: 02b0d4b688cc - main - sys/cdefs.h: add __noexcept and __noexcept_if
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 02 Feb 2024 18:16:58 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=02b0d4b688cc4deb14cb6e7534a2a4958e48b753 commit 02b0d4b688cc4deb14cb6e7534a2a4958e48b753 Author: Lexi Winter <lexi@le-Fay.ORG> AuthorDate: 2024-02-02 16:41:40 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-02-02 18:11:17 +0000 sys/cdefs.h: add __noexcept and __noexcept_if These macros provide the C++11 noexcept and noexcept(...) keywords if we're compiling in a C++11 environment. Otherwise, they expand to an empty string. This will be used to add the required noexcept specifier to several libc functions as required in C++11. MFC after: 2 weeks Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1085 --- sys/sys/cdefs.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index fcc90b4d8aee..206cc569c55a 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -358,6 +358,17 @@ #endif #endif +/* + * noexcept keyword added in C++11. + */ +#if defined(__cplusplus) && __cplusplus >= 201103L +#define __noexcept noexcept +#define __noexcept_if(__c) noexcept(__c) +#else +#define __noexcept +#define __noexcept_if(__c) +#endif + /* * We use `__restrict' as a way to define the `restrict' type qualifier * without disturbing older software that is unaware of C99 keywords.