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/. */ 6 7 /* 8 * Implements a workaround for compilers which do not support the C++11 nullptr 9 * constant. 10 */ 11 12 #ifndef mozilla_NullPtr_h 13 #define mozilla_NullPtr_h 14 15 // C::B patch: to fix multiple defines of nullptr 16 #include "prep.h" // C::B Header that defines nullptr 17 18 #include "mozilla/Compiler.h" 19 20 #if defined(__clang__) 21 # ifndef __has_extension 22 # define __has_extension __has_feature 23 # endif 24 # if __has_extension(cxx_nullptr) 25 # define MOZ_HAVE_CXX11_NULLPTR 26 # endif 27 #elif defined(__GNUC__) 28 # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L 29 # if MOZ_GCC_VERSION_AT_LEAST(4, 6, 0) 30 # define MOZ_HAVE_CXX11_NULLPTR 31 # endif 32 # endif 33 #elif defined(_MSC_VER) && _MSC_VER >= 1600 34 # define MOZ_HAVE_CXX11_NULLPTR 35 #endif 36 37 /** 38 * Use C++11 nullptr if available; otherwise use __null for gcc, or a 0 literal 39 * with the correct size to match the size of a pointer on a given platform. 40 */ 41 42 #ifndef MOZ_HAVE_CXX11_NULLPTR 43 # if defined(__GNUC__) 44 # define nullptr __null 45 # elif defined(_WIN64) 46 # define nullptr 0LL 47 # else 48 # define nullptr 0L 49 # endif 50 #endif 51 52 #endif /* mozilla_NullPtr_h */ 53