| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_CPP_LOGGING_H_ | 5 #ifndef PPAPI_CPP_LOGGING_H_ |
| 6 #define PPAPI_CPP_LOGGING_H_ | 6 #define PPAPI_CPP_LOGGING_H_ |
| 7 | 7 |
| 8 /// @file | 8 /// @file |
| 9 /// This file defines two macro asserts. | 9 /// This file defines two macro asserts. |
| 10 | 10 |
| 11 #include <cassert> | 11 #include <cassert> |
| 12 | 12 |
| 13 /// This macro asserts that 'a' evaluates to true. In debug mode, this macro | 13 /// This macro asserts that 'a' evaluates to true. In debug mode, this macro |
| 14 /// will crash the program if the assertion evaluates to false. It (typically) | 14 /// will crash the program if the assertion evaluates to false. It (typically) |
| 15 /// has no effect in release mode. | 15 /// has no effect in release mode. |
| 16 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
| 16 #define PP_DCHECK(a) assert(a) | 17 #define PP_DCHECK(a) assert(a) |
| 18 #else // !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
| 19 #define PP_DCHECK(a) |
| 20 #endif // !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
| 17 | 21 |
| 18 /// This macro asserts false in debug builds. It's used in code paths that you | 22 /// This macro asserts false in debug builds. It's used in code paths that you |
| 19 /// don't expect to execute. | 23 /// don't expect to execute. |
| 20 /// | 24 /// |
| 21 /// <strong>Example:</strong> | 25 /// <strong>Example:</strong> |
| 22 /// | 26 /// |
| 23 /// @code | 27 /// @code |
| 24 /// if (!pointer) { | 28 /// if (!pointer) { |
| 25 /// // Pointer wasn't valid! This shouldn't happen. | 29 /// // Pointer wasn't valid! This shouldn't happen. |
| 26 /// PP_NOTREACHED(); | 30 /// PP_NOTREACHED(); |
| 27 /// return; | 31 /// return; |
| 28 /// } | 32 /// } |
| 29 /// // Do stuff to the pointer, since you know it's valid. | 33 /// // Do stuff to the pointer, since you know it's valid. |
| 30 /// pointer->DoSomething(); | 34 /// pointer->DoSomething(); |
| 31 /// @endcode | 35 /// @endcode |
| 36 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
| 32 #define PP_NOTREACHED() assert(false) | 37 #define PP_NOTREACHED() assert(false) |
| 38 #else // !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
| 39 #define PP_NOTREACHED() |
| 40 #endif // !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
| 33 | 41 |
| 34 #endif // PPAPI_CPP_LOGGING_H_ | 42 #endif // PPAPI_CPP_LOGGING_H_ |
| OLD | NEW |