Web server based weather station using Sparkfun Weather Meters.

Dependencies:   FatFileSystem mbed WeatherMeters SDFileSystem

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers debug.h Source File

debug.h

00001 /* Copyright 2011 Adam Green (http://mbed.org/users/AdamGreen/)
00002 
00003    Licensed under the Apache License, Version 2.0 (the "License");
00004    you may not use this file except in compliance with the License.
00005    You may obtain a copy of the License at
00006 
00007        http://www.apache.org/licenses/LICENSE-2.0
00008 
00009    Unless required by applicable law or agreed to in writing, software
00010    distributed under the License is distributed on an "AS IS" BASIS,
00011    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012    See the License for the specific language governing permissions and
00013    limitations under the License.
00014 */
00015 /* Header file for debug related functionality. */
00016 #ifndef DEBUG_H_
00017 #define DEBUG_H_
00018 
00019 
00020 #include <mbed.h>
00021 
00022 
00023 // Assert related macroes and functions.
00024 #ifndef NDEBUG
00025     static __inline int __AssertLog(const char* pAssert, const char* pFilename, unsigned int LineNumber)
00026     {
00027         static const char  UsersDir[] = "/users/";
00028         const char*        pUsers;
00029         
00030         // Skip long workspace source filename prefix.
00031         pUsers = strstr(pFilename, UsersDir);
00032         if (pUsers)
00033         {
00034             pUsers = strchr(pUsers + sizeof(UsersDir) - 1, '/');
00035             if (pUsers)
00036             {
00037                 pFilename = pUsers + 1;
00038             }
00039         }
00040    
00041         error("%s:%u Assertion failure: %s\r\n", pFilename, LineNumber, pAssert);
00042         return 0;
00043     }
00044     #define assert(X) ((X) || __AssertLog(#X, __FILE__, __LINE__))
00045 #else
00046     static __inline void __AssertLog()
00047     {
00048     }
00049     #define assert(X) __AssertLog()
00050 #endif // NDEBUG
00051 
00052 
00053 
00054 #endif /* DEBUG_H_ */