OLD | NEW |
| (Empty) |
1 // Copyright 2005-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 // | |
16 // Take over ATLASSERT | |
17 // | |
18 | |
19 #ifndef OMAHA_BASE_ATLASSERT_H_ | |
20 #define OMAHA_BASE_ATLASSERT_H_ | |
21 | |
22 #include <tchar.h> | |
23 | |
24 #ifdef _DEBUG | |
25 #ifndef DEBUG | |
26 #error DEBUG and _DEBUG must be in sync | |
27 #endif | |
28 #endif | |
29 | |
30 namespace omaha { | |
31 | |
32 enum ReportType { | |
33 R_INFO = 1, // Not an error, used for accumulating statistics. | |
34 R_WARNING, // May or may not be an error. | |
35 R_ERROR, // Definitely an error. | |
36 R_FATAL // halt program == ASSERT for release mode. | |
37 }; | |
38 | |
39 enum DebugReportKind { | |
40 DEBUGREPORT_NONE = 0, | |
41 DEBUGREPORT_ASSERT = 1, | |
42 DEBUGREPORT_REPORT = 2, | |
43 DEBUGREPORT_ABORT = 3 | |
44 }; | |
45 | |
46 #ifdef DEBUG | |
47 extern "C" bool DebugReport(unsigned int id, | |
48 omaha::ReportType type, | |
49 const char* expr, | |
50 const TCHAR* message, | |
51 const char* filename, | |
52 int linenumber, | |
53 omaha::DebugReportKind debug_report_kind); | |
54 #ifndef ATLASSERT | |
55 #define ATLASSERT(expr) \ | |
56 do { \ | |
57 if (!(expr)) { \ | |
58 DebugReport(0, \ | |
59 omaha::R_FATAL, \ | |
60 #expr, \ | |
61 _T("ATL assertion"), \ | |
62 __FILE__, \ | |
63 __LINE__, \ | |
64 omaha::DEBUGREPORT_ASSERT); \ | |
65 } \ | |
66 } while (0) | |
67 #endif | |
68 #else | |
69 #ifndef ATLASSERT | |
70 #define ATLASSERT(expr) ((void)0) | |
71 #endif | |
72 #endif | |
73 | |
74 } // namespace omaha | |
75 | |
76 #endif // OMAHA_BASE_ATLASSERT_H_ | |
OLD | NEW |