Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FatFileSystem mbed WeatherMeters SDFileSystem
debug.h@0:1a61c61d0845, 2012-04-03 (annotated)
- Committer:
- dcoban
- Date:
- Tue Apr 03 18:43:13 2012 +0000
- Revision:
- 0:1a61c61d0845
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| dcoban | 0:1a61c61d0845 | 1 | /* Copyright 2011 Adam Green (http://mbed.org/users/AdamGreen/) | 
| dcoban | 0:1a61c61d0845 | 2 | |
| dcoban | 0:1a61c61d0845 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); | 
| dcoban | 0:1a61c61d0845 | 4 | you may not use this file except in compliance with the License. | 
| dcoban | 0:1a61c61d0845 | 5 | You may obtain a copy of the License at | 
| dcoban | 0:1a61c61d0845 | 6 | |
| dcoban | 0:1a61c61d0845 | 7 | http://www.apache.org/licenses/LICENSE-2.0 | 
| dcoban | 0:1a61c61d0845 | 8 | |
| dcoban | 0:1a61c61d0845 | 9 | Unless required by applicable law or agreed to in writing, software | 
| dcoban | 0:1a61c61d0845 | 10 | distributed under the License is distributed on an "AS IS" BASIS, | 
| dcoban | 0:1a61c61d0845 | 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| dcoban | 0:1a61c61d0845 | 12 | See the License for the specific language governing permissions and | 
| dcoban | 0:1a61c61d0845 | 13 | limitations under the License. | 
| dcoban | 0:1a61c61d0845 | 14 | */ | 
| dcoban | 0:1a61c61d0845 | 15 | /* Header file for debug related functionality. */ | 
| dcoban | 0:1a61c61d0845 | 16 | #ifndef DEBUG_H_ | 
| dcoban | 0:1a61c61d0845 | 17 | #define DEBUG_H_ | 
| dcoban | 0:1a61c61d0845 | 18 | |
| dcoban | 0:1a61c61d0845 | 19 | |
| dcoban | 0:1a61c61d0845 | 20 | #include <mbed.h> | 
| dcoban | 0:1a61c61d0845 | 21 | |
| dcoban | 0:1a61c61d0845 | 22 | |
| dcoban | 0:1a61c61d0845 | 23 | // Assert related macroes and functions. | 
| dcoban | 0:1a61c61d0845 | 24 | #ifndef NDEBUG | 
| dcoban | 0:1a61c61d0845 | 25 | static __inline int __AssertLog(const char* pAssert, const char* pFilename, unsigned int LineNumber) | 
| dcoban | 0:1a61c61d0845 | 26 | { | 
| dcoban | 0:1a61c61d0845 | 27 | static const char UsersDir[] = "/users/"; | 
| dcoban | 0:1a61c61d0845 | 28 | const char* pUsers; | 
| dcoban | 0:1a61c61d0845 | 29 | |
| dcoban | 0:1a61c61d0845 | 30 | // Skip long workspace source filename prefix. | 
| dcoban | 0:1a61c61d0845 | 31 | pUsers = strstr(pFilename, UsersDir); | 
| dcoban | 0:1a61c61d0845 | 32 | if (pUsers) | 
| dcoban | 0:1a61c61d0845 | 33 | { | 
| dcoban | 0:1a61c61d0845 | 34 | pUsers = strchr(pUsers + sizeof(UsersDir) - 1, '/'); | 
| dcoban | 0:1a61c61d0845 | 35 | if (pUsers) | 
| dcoban | 0:1a61c61d0845 | 36 | { | 
| dcoban | 0:1a61c61d0845 | 37 | pFilename = pUsers + 1; | 
| dcoban | 0:1a61c61d0845 | 38 | } | 
| dcoban | 0:1a61c61d0845 | 39 | } | 
| dcoban | 0:1a61c61d0845 | 40 | |
| dcoban | 0:1a61c61d0845 | 41 | error("%s:%u Assertion failure: %s\r\n", pFilename, LineNumber, pAssert); | 
| dcoban | 0:1a61c61d0845 | 42 | return 0; | 
| dcoban | 0:1a61c61d0845 | 43 | } | 
| dcoban | 0:1a61c61d0845 | 44 | #define assert(X) ((X) || __AssertLog(#X, __FILE__, __LINE__)) | 
| dcoban | 0:1a61c61d0845 | 45 | #else | 
| dcoban | 0:1a61c61d0845 | 46 | static __inline void __AssertLog() | 
| dcoban | 0:1a61c61d0845 | 47 | { | 
| dcoban | 0:1a61c61d0845 | 48 | } | 
| dcoban | 0:1a61c61d0845 | 49 | #define assert(X) __AssertLog() | 
| dcoban | 0:1a61c61d0845 | 50 | #endif // NDEBUG | 
| dcoban | 0:1a61c61d0845 | 51 | |
| dcoban | 0:1a61c61d0845 | 52 | |
| dcoban | 0:1a61c61d0845 | 53 | |
| dcoban | 0:1a61c61d0845 | 54 | #endif /* DEBUG_H_ */ |