Fork of the official mbed C/C++ SDK provides the software platform and libraries to build your applications. The fork has the documentation converted to Doxygen format

Dependents:   NervousPuppySprintOne NervousPuppySprint2602 Robot WarehouseBot1 ... more

Fork of mbed by mbed official

Committer:
screamer
Date:
Wed Oct 24 10:44:49 2012 +0000
Revision:
43:aff670d0d510
Parent:
27:7110ebee3484
Conversion of the classes documentation to Doxygen format

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rolf.meyer@arm.com 11:1c1ebd0324fa 1 /* mbed Microcontroller Library - error
rolf.meyer@arm.com 11:1c1ebd0324fa 2 * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
rolf.meyer@arm.com 11:1c1ebd0324fa 3 */
rolf.meyer@arm.com 11:1c1ebd0324fa 4
rolf.meyer@arm.com 11:1c1ebd0324fa 5 #ifndef MBED_ERROR_H
rolf.meyer@arm.com 11:1c1ebd0324fa 6 #define MBED_ERROR_H
rolf.meyer@arm.com 11:1c1ebd0324fa 7
screamer 43:aff670d0d510 8 /** To generate a fatal compile-time error, you can use the pre-processor #error directive.
rolf.meyer@arm.com 11:1c1ebd0324fa 9 *
screamer 43:aff670d0d510 10 * @code
screamer 43:aff670d0d510 11 * #error "That shouldn't have happened!"
screamer 43:aff670d0d510 12 * @endcode
rolf.meyer@arm.com 11:1c1ebd0324fa 13 *
rolf.meyer@arm.com 11:1c1ebd0324fa 14 * If the compiler evaluates this line, it will report the error and stop the compile.
rolf.meyer@arm.com 11:1c1ebd0324fa 15 *
rolf.meyer@arm.com 11:1c1ebd0324fa 16 * For example, you could use this to check some user-defined compile-time variables:
screamer 43:aff670d0d510 17 *
screamer 43:aff670d0d510 18 * @code
screamer 43:aff670d0d510 19 * #define NUM_PORTS 7
screamer 43:aff670d0d510 20 * #if (NUM_PORTS > 4)
screamer 43:aff670d0d510 21 * #error "NUM_PORTS must be less than 4"
screamer 43:aff670d0d510 22 * #endif
screamer 43:aff670d0d510 23 * @endcode
rolf.meyer@arm.com 11:1c1ebd0324fa 24 *
rolf.meyer@arm.com 11:1c1ebd0324fa 25 * Reporting Run-Time Errors:
rolf.meyer@arm.com 11:1c1ebd0324fa 26 * To generate a fatal run-time error, you can use the mbed error() function.
rolf.meyer@arm.com 11:1c1ebd0324fa 27 *
screamer 43:aff670d0d510 28 * @code
screamer 43:aff670d0d510 29 * error("That shouldn't have happened!");
screamer 43:aff670d0d510 30 * @endcode
rolf.meyer@arm.com 11:1c1ebd0324fa 31 *
rolf.meyer@arm.com 11:1c1ebd0324fa 32 * If the mbed running the program executes this function, it will print the
rolf.meyer@arm.com 11:1c1ebd0324fa 33 * message via the USB serial port, and then die with the blue lights of death!
rolf.meyer@arm.com 11:1c1ebd0324fa 34 *
rolf.meyer@arm.com 11:1c1ebd0324fa 35 * The message can use printf-style formatting, so you can report variables in the
rolf.meyer@arm.com 11:1c1ebd0324fa 36 * message too. For example, you could use this to check a run-time condition:
rolf.meyer@arm.com 11:1c1ebd0324fa 37 *
screamer 43:aff670d0d510 38 * @code
screamer 43:aff670d0d510 39 * if(x >= 5) {
screamer 43:aff670d0d510 40 * error("expected x to be less than 5, but got %d", x);
screamer 43:aff670d0d510 41 * }
screamer 43:aff670d0d510 42 * #endcode
rolf.meyer@arm.com 11:1c1ebd0324fa 43 */
rolf.meyer@arm.com 11:1c1ebd0324fa 44
rolf.meyer@arm.com 11:1c1ebd0324fa 45 #if 0 // for documentation only
screamer 43:aff670d0d510 46 /** Report a fatal runtime error
rolf.meyer@arm.com 11:1c1ebd0324fa 47 *
screamer 43:aff670d0d510 48 * Outputs the specified error message to stderr so it will appear via the USB
screamer 43:aff670d0d510 49 * serial port, and then calls exit(1) to die with the blue lights of death.
rolf.meyer@arm.com 11:1c1ebd0324fa 50 *
screamer 43:aff670d0d510 51 * @param format printf-style format string, followed by associated variables
rolf.meyer@arm.com 11:1c1ebd0324fa 52 */
rolf.meyer@arm.com 11:1c1ebd0324fa 53 void error(const char* format, ...);
rolf.meyer@arm.com 11:1c1ebd0324fa 54 #endif
rolf.meyer@arm.com 11:1c1ebd0324fa 55
rolf.meyer@arm.com 11:1c1ebd0324fa 56 #include <stdlib.h>
rolf.meyer@arm.com 11:1c1ebd0324fa 57
rolf.meyer@arm.com 11:1c1ebd0324fa 58 #ifdef NDEBUG
rolf.meyer@arm.com 11:1c1ebd0324fa 59 #define error(...) (exit(1))
rolf.meyer@arm.com 11:1c1ebd0324fa 60 #else
rolf.meyer@arm.com 11:1c1ebd0324fa 61 #include <stdio.h>
rolf.meyer@arm.com 11:1c1ebd0324fa 62 #define error(...) (fprintf(stderr, __VA_ARGS__), exit(1))
rolf.meyer@arm.com 11:1c1ebd0324fa 63 #endif
rolf.meyer@arm.com 11:1c1ebd0324fa 64
rolf.meyer@arm.com 11:1c1ebd0324fa 65 #endif