Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_polyfill / standard_library_public / pw_polyfill / standard_library / namespace.h
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 #pragma once
15
16 // libc++ uses a special namespace for standard library headers. Use this
17 // namespace via the defines in <__config>.
18 #if defined(_LIBCPP_VERSION) && __has_include(<__config>)
19
20 #include <__config>
21
22 #define _PW_POLYFILL_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
23 #define _PW_POLYFILL_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
24
25 #else  // Directly use the std namespace in GCC.
26
27 #define _PW_POLYFILL_BEGIN_NAMESPACE_STD namespace std {
28 #define _PW_POLYFILL_END_NAMESPACE_STD }  // namespace std
29
30 // Cannot compile when using libc++ without the <__config> header.
31 #ifdef _LIBCPP_VERSION
32 static_assert(
33     false,
34     "Compiling against libc++, but the <__config> header is not available. "
35     "The <__config> header provides various _LIBCPP defines used internally "
36     "by libc++. pw_polyfill needs this header for the "
37     "_LIBCPP_BEGIN_NAMESPACE_STD and _LIBCPP_END_NAMESPACE_STD macros, which "
38     "specify the namespace to use for the standard library. "
39     ""
40     "If you see this message, you may be compiling with Clang, but without "
41     "libc++, in which case a fake <__config> header should be provided. "
42     "Alternately, libc++ may have been updated and no longer provides "
43     "<__config>, in which this file should be updated to properly "
44     "set _PW_POLYFILL_BEGIN_NAMESPACE_STD and _PW_POLYFILL_END_NAMESPACE_STD.");
45
46 #endif  // _LIBCPP_VERSION
47
48 #endif  // defined(_LIBCPP_VERSION) && __has_include(<__config>)