| // Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. | |
| // | |
| // Redistribution and use in source and binary forms, with or without | |
| // modification, are permitted provided that the following conditions are | |
| // met: | |
| // | |
| // * Redistributions of source code must retain the above copyright | |
| // notice, this list of conditions and the following disclaimer. | |
| // * Redistributions in binary form must reproduce the above | |
| // copyright notice, this list of conditions and the following disclaimer | |
| // in the documentation and/or other materials provided with the | |
| // distribution. | |
| // * Neither the name of Google Inc. nor the name Chromium Embedded | |
| // Framework nor the names of its contributors may be used to endorse | |
| // or promote products derived from this software without specific prior | |
| // written permission. | |
| // | |
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| #ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_ | |
| #define CEF_INCLUDE_BASE_CEF_BUILD_H_ | |
| #pragma once | |
| #if defined(USING_CHROMIUM_INCLUDES) | |
| // When building CEF include the Chromium header directly. | |
| #include "base/compiler_specific.h" | |
| #else // !USING_CHROMIUM_INCLUDES | |
| // The following is substantially similar to the Chromium implementation. | |
| // If the Chromium implementation diverges the below implementation should be | |
| // updated to match. | |
| #if defined(_WIN32) | |
| #ifndef OS_WIN | |
| #define OS_WIN 1 | |
| #endif | |
| #elif defined(__APPLE__) | |
| #ifndef OS_MACOSX | |
| #define OS_MACOSX 1 | |
| #endif | |
| #elif defined(__linux__) | |
| #ifndef OS_LINUX | |
| #define OS_LINUX 1 | |
| #endif | |
| #else | |
| #error Please add support for your platform in cef_build.h | |
| #endif | |
| // For access to standard POSIXish features, use OS_POSIX instead of a | |
| // more specific macro. | |
| #if defined(OS_MACOSX) || defined(OS_LINUX) | |
| #ifndef OS_POSIX | |
| #define OS_POSIX 1 | |
| #endif | |
| #endif | |
| // Compiler detection. | |
| #if defined(__GNUC__) | |
| #ifndef COMPILER_GCC | |
| #define COMPILER_GCC 1 | |
| #endif | |
| #elif defined(_MSC_VER) | |
| #ifndef COMPILER_MSVC | |
| #define COMPILER_MSVC 1 | |
| #endif | |
| #else | |
| #error Please add support for your compiler in cef_build.h | |
| #endif | |
| // Processor architecture detection. For more info on what's defined, see: | |
| // http://msdn.microsoft.com/en-us/library/b0084kay.aspx | |
| // http://www.agner.org/optimize/calling_conventions.pdf | |
| // or with gcc, run: "echo | gcc -E -dM -" | |
| #if defined(_M_X64) || defined(__x86_64__) | |
| #define ARCH_CPU_X86_FAMILY 1 | |
| #define ARCH_CPU_X86_64 1 | |
| #define ARCH_CPU_64_BITS 1 | |
| #define ARCH_CPU_LITTLE_ENDIAN 1 | |
| #elif defined(_M_IX86) || defined(__i386__) | |
| #define ARCH_CPU_X86_FAMILY 1 | |
| #define ARCH_CPU_X86 1 | |
| #define ARCH_CPU_32_BITS 1 | |
| #define ARCH_CPU_LITTLE_ENDIAN 1 | |
| #elif defined(__ARMEL__) | |
| #define ARCH_CPU_ARM_FAMILY 1 | |
| #define ARCH_CPU_ARMEL 1 | |
| #define ARCH_CPU_32_BITS 1 | |
| #define ARCH_CPU_LITTLE_ENDIAN 1 | |
| #elif defined(__aarch64__) || defined(_M_ARM64) | |
| #define ARCH_CPU_ARM_FAMILY 1 | |
| #define ARCH_CPU_ARM64 1 | |
| #define ARCH_CPU_64_BITS 1 | |
| #define ARCH_CPU_LITTLE_ENDIAN 1 | |
| #elif defined(__pnacl__) | |
| #define ARCH_CPU_32_BITS 1 | |
| #define ARCH_CPU_LITTLE_ENDIAN 1 | |
| #elif defined(__MIPSEL__) | |
| #define ARCH_CPU_MIPS_FAMILY 1 | |
| #define ARCH_CPU_MIPSEL 1 | |
| #define ARCH_CPU_32_BITS 1 | |
| #define ARCH_CPU_LITTLE_ENDIAN 1 | |
| #else | |
| #error Please add support for your architecture in cef_build.h | |
| #endif | |
| // Type detection for wchar_t. | |
| #if defined(OS_WIN) | |
| #define WCHAR_T_IS_UTF16 | |
| #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ | |
| (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) | |
| #define WCHAR_T_IS_UTF32 | |
| #elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ | |
| (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) | |
| // On Posix, we'll detect short wchar_t, but projects aren't guaranteed to | |
| // compile in this mode (in particular, Chrome doesn't). This is intended for | |
| // other projects using base who manage their own dependencies and make sure | |
| // short wchar works for them. | |
| #define WCHAR_T_IS_UTF16 | |
| #else | |
| #error Please add support for your compiler in cef_build.h | |
| #endif | |
| // Annotate a function indicating the caller must examine the return value. | |
| // Use like: | |
| // int foo() WARN_UNUSED_RESULT; | |
| // To explicitly ignore a result, see |ignore_result()| in <base/macros.h>. | |
| #ifndef WARN_UNUSED_RESULT | |
| #if defined(COMPILER_GCC) | |
| #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | |
| #else | |
| #define WARN_UNUSED_RESULT | |
| #endif | |
| #endif // WARN_UNUSED_RESULT | |
| // Annotate a typedef or function indicating it's ok if it's not used. | |
| // Use like: | |
| // typedef Foo Bar ALLOW_UNUSED_TYPE; | |
| #ifndef ALLOW_UNUSED_TYPE | |
| #if defined(COMPILER_GCC) | |
| #define ALLOW_UNUSED_TYPE __attribute__((unused)) | |
| #else | |
| #define ALLOW_UNUSED_TYPE | |
| #endif | |
| #endif // ALLOW_UNUSED_TYPE | |
| // Annotate a variable indicating it's ok if the variable is not used. | |
| // (Typically used to silence a compiler warning when the assignment | |
| // is important for some other reason.) | |
| // Use like: | |
| // int x = ...; | |
| // ALLOW_UNUSED_LOCAL(x); | |
| #ifndef ALLOW_UNUSED_LOCAL | |
| #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 | |
| #endif | |
| // Sanitizers annotations. | |
| #if defined(__has_attribute) | |
| #if __has_attribute(no_sanitize) | |
| #define NO_SANITIZE(what) __attribute__((no_sanitize(what))) | |
| #endif | |
| #endif | |
| #if !defined(NO_SANITIZE) | |
| #define NO_SANITIZE(what) | |
| #endif | |
| #endif // !USING_CHROMIUM_INCLUDES | |
| // Annotate a virtual method indicating it must be overriding a virtual method | |
| // in the parent class. | |
| // Use like: | |
| // void foo() OVERRIDE; | |
| // NOTE: This define should only be used in classes exposed to the client since | |
| // C++11 support may not be enabled in client applications. CEF internal classes | |
| // should use the `override` keyword directly. | |
| #ifndef OVERRIDE | |
| #if defined(__clang__) | |
| #define OVERRIDE override | |
| #elif defined(COMPILER_MSVC) && _MSC_VER >= 1600 | |
| // Visual Studio 2010 and later support override. | |
| #define OVERRIDE override | |
| #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ | |
| (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 | |
| // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. | |
| #define OVERRIDE override | |
| #else | |
| #define OVERRIDE | |
| #endif | |
| #endif // OVERRIDE | |
| // Check for C++11 template alias support which was added in VS2013 and GCC4.7. | |
| // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf | |
| #if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1800) || \ | |
| (defined(__GNUC__) && \ | |
| (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700)) | |
| #define HAS_CPP11_TEMPLATE_ALIAS_SUPPORT | |
| #endif | |
| #endif // CEF_INCLUDE_BASE_CEF_BUILD_H_ |