Simon Ford / debug

Dependents:   pyrocommander Projektni_zadatak_Analogni_sat ProjetOctopode

Committer:
simon
Date:
Sat Aug 04 22:07:09 2012 +0000
Revision:
3:b6e4a45bd418
Parent:
2:24afdea2d903
Trying to get doxygen for global functions to work by adding file attribute

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simon 0:aa1c8e69d98f 1 /* Copyright (c) 2012 mbed.org, MIT License
simon 0:aa1c8e69d98f 2 *
simon 0:aa1c8e69d98f 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
simon 0:aa1c8e69d98f 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
simon 0:aa1c8e69d98f 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
simon 0:aa1c8e69d98f 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
simon 0:aa1c8e69d98f 7 * furnished to do so, subject to the following conditions:
simon 0:aa1c8e69d98f 8 *
simon 0:aa1c8e69d98f 9 * The above copyright notice and this permission notice shall be included in all copies or
simon 0:aa1c8e69d98f 10 * substantial portions of the Software.
simon 0:aa1c8e69d98f 11 *
simon 0:aa1c8e69d98f 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
simon 0:aa1c8e69d98f 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
simon 0:aa1c8e69d98f 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
simon 0:aa1c8e69d98f 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
simon 0:aa1c8e69d98f 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
simon 0:aa1c8e69d98f 17 */
simon 0:aa1c8e69d98f 18
simon 0:aa1c8e69d98f 19 #ifndef DEBUG_H
simon 0:aa1c8e69d98f 20 #define DEBUG_H
simon 0:aa1c8e69d98f 21
simon 3:b6e4a45bd418 22 /** @file debug.h */
simon 2:24afdea2d903 23
simon 0:aa1c8e69d98f 24 #ifndef NDEBUG
simon 0:aa1c8e69d98f 25
simon 0:aa1c8e69d98f 26 #include <stdarg.h>
simon 0:aa1c8e69d98f 27 #include <stdio.h>
simon 0:aa1c8e69d98f 28
simon 1:12ff10369961 29 /** Output a debug message
simon 1:12ff10369961 30 *
simon 1:12ff10369961 31 * @param format printf-style format string, followed by variables
simon 1:12ff10369961 32 */
simon 0:aa1c8e69d98f 33 static inline void debug(const char *format, ...) {
simon 0:aa1c8e69d98f 34 va_list args;
simon 0:aa1c8e69d98f 35 va_start(args, format);
simon 0:aa1c8e69d98f 36 vfprintf(stderr, format, args);
simon 0:aa1c8e69d98f 37 va_end(args);
simon 0:aa1c8e69d98f 38 }
simon 0:aa1c8e69d98f 39
simon 1:12ff10369961 40 /** Conditionally output a debug message
simon 1:12ff10369961 41 *
simon 1:12ff10369961 42 * @param condition output only if condition is true
simon 1:12ff10369961 43 * @param format printf-style format string, followed by variables
simon 1:12ff10369961 44 */
simon 0:aa1c8e69d98f 45 static inline void debug(bool condition, const char *format, ...) {
simon 0:aa1c8e69d98f 46 if(condition) {
simon 0:aa1c8e69d98f 47 va_list args;
simon 0:aa1c8e69d98f 48 va_start(args, format);
simon 0:aa1c8e69d98f 49 vfprintf(stderr, format, args);
simon 0:aa1c8e69d98f 50 va_end(args);
simon 0:aa1c8e69d98f 51 }
simon 0:aa1c8e69d98f 52 }
simon 0:aa1c8e69d98f 53
simon 0:aa1c8e69d98f 54 #else
simon 0:aa1c8e69d98f 55
simon 0:aa1c8e69d98f 56 static inline void debug(const char *format, ...) {}
simon 0:aa1c8e69d98f 57 static inline void debug(bool condition, const char *format, ...) {}
simon 0:aa1c8e69d98f 58
simon 0:aa1c8e69d98f 59 #endif
simon 0:aa1c8e69d98f 60
simon 0:aa1c8e69d98f 61 #endif