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
This commit is contained in:
Lexi Winter 2024-02-02 09:41:40 -07:00 committed by Warner Losh
parent 0e867a4911
commit 02b0d4b688

View file

@ -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.