1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/chromium/src/base/compiler_specific.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef BASE_COMPILER_SPECIFIC_H_ 1.9 +#define BASE_COMPILER_SPECIFIC_H_ 1.10 + 1.11 +#include "build/build_config.h" 1.12 + 1.13 +#if defined(COMPILER_MSVC) 1.14 + 1.15 +// Macros for suppressing and disabling warnings on MSVC. 1.16 +// 1.17 +// Warning numbers are enumerated at: 1.18 +// http://msdn.microsoft.com/en-us/library/8x5x43k7(VS.80).aspx 1.19 +// 1.20 +// The warning pragma: 1.21 +// http://msdn.microsoft.com/en-us/library/2c8f766e(VS.80).aspx 1.22 +// 1.23 +// Using __pragma instead of #pragma inside macros: 1.24 +// http://msdn.microsoft.com/en-us/library/d9x1s805.aspx 1.25 + 1.26 +// MSVC_SUPPRESS_WARNING disables warning |n| for the remainder of the line and 1.27 +// for the next line of the source file. 1.28 +#define MSVC_SUPPRESS_WARNING(n) __pragma(warning(suppress:n)) 1.29 + 1.30 +// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. 1.31 +// The warning remains disabled until popped by MSVC_POP_WARNING. 1.32 +#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \ 1.33 + __pragma(warning(disable:n)) 1.34 + 1.35 +// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level 1.36 +// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all 1.37 +// warnings. 1.38 +#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) 1.39 + 1.40 +// Pop effects of innermost MSVC_PUSH_* macro. 1.41 +#define MSVC_POP_WARNING() __pragma(warning(pop)) 1.42 + 1.43 +#define MSVC_DISABLE_OPTIMIZE() __pragma(optimize("", off)) 1.44 +#define MSVC_ENABLE_OPTIMIZE() __pragma(optimize("", on)) 1.45 + 1.46 +// Allows |this| to be passed as an argument in constructor initializer lists. 1.47 +// This uses push/pop instead of the seemingly simpler suppress feature to avoid 1.48 +// having the warning be disabled for more than just |code|. 1.49 +// 1.50 +// Example usage: 1.51 +// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} 1.52 +// 1.53 +// Compiler warning C4355: 'this': used in base member initializer list: 1.54 +// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx 1.55 +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \ 1.56 + code \ 1.57 + MSVC_POP_WARNING() 1.58 + 1.59 +#else // Not MSVC 1.60 + 1.61 +#define MSVC_SUPPRESS_WARNING(n) 1.62 +#define MSVC_PUSH_DISABLE_WARNING(n) 1.63 +#define MSVC_PUSH_WARNING_LEVEL(n) 1.64 +#define MSVC_POP_WARNING() 1.65 +#define MSVC_DISABLE_OPTIMIZE() 1.66 +#define MSVC_ENABLE_OPTIMIZE() 1.67 +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code 1.68 + 1.69 +#endif // COMPILER_MSVC 1.70 + 1.71 + 1.72 +#if defined(COMPILER_GCC) 1.73 +#define ALLOW_UNUSED __attribute__((unused)) 1.74 +#define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 1.75 +#else // Not GCC 1.76 +#define ALLOW_UNUSED 1.77 +#define WARN_UNUSED_RESULT 1.78 +#endif 1.79 + 1.80 +#endif // BASE_COMPILER_SPECIFIC_H_