1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * Implements a workaround for compilers which do not support the C++11 nullptr
12 #ifndef mozilla_NullPtr_h
13 #define mozilla_NullPtr_h
15 #if defined(__clang__)
16 # ifndef __has_extension
17 # define __has_extension __has_feature
19 # if __has_extension(cxx_nullptr)
20 # define MOZ_HAVE_CXX11_NULLPTR
22 #elif defined(__GNUC__)
23 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
24 # include "mozilla/Compiler.h"
25 # if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0)
26 # define MOZ_HAVE_CXX11_NULLPTR
29 #elif _MSC_VER >= 1600
30 # define MOZ_HAVE_CXX11_NULLPTR
34 * Use C++11 nullptr if available; otherwise use __null for gcc, or a 0 literal
35 * with the correct size to match the size of a pointer on a given platform.
38 #ifndef MOZ_HAVE_CXX11_NULLPTR
39 # if defined(__GNUC__)
40 # define nullptr __null
41 # elif defined(_WIN64)
48 #endif /* mozilla_NullPtr_h */