I messed up the merge, so pushing it over to another repo so I don't lose it. Will tidy up and remove later
Dependencies: BufferedSerial FatFileSystemCpp mbed
error.h
00001 /* mbed Microcontroller Library - error 00002 * Copyright (c) 2006-2009 ARM Limited. All rights reserved. 00003 * sford 00004 */ 00005 00006 #ifndef MBED_ERROR_H 00007 #define MBED_ERROR_H 00008 00009 /* Reporting Compile-Time Errors: 00010 * To generate a fatal compile-time error, you can use the pre-processor #error directive. 00011 * 00012 * > #error "That shouldn't have happened!" 00013 * 00014 * If the compiler evaluates this line, it will report the error and stop the compile. 00015 * 00016 * For example, you could use this to check some user-defined compile-time variables: 00017 * 00018 * > #define NUM_PORTS 7 00019 * > #if (NUM_PORTS > 4) 00020 * > #error "NUM_PORTS must be less than 4" 00021 * > #endif 00022 * 00023 * Reporting Run-Time Errors: 00024 * To generate a fatal run-time error, you can use the mbed error() function. 00025 * 00026 * > error("That shouldn't have happened!"); 00027 * 00028 * If the mbed running the program executes this function, it will print the 00029 * message via the USB serial port, and then die with the blue lights of death! 00030 * 00031 * The message can use printf-style formatting, so you can report variables in the 00032 * message too. For example, you could use this to check a run-time condition: 00033 * 00034 * > if(x >= 5) { 00035 * > error("expected x to be less than 5, but got %d", x); 00036 * > } 00037 */ 00038 00039 #if 0 // for documentation only 00040 /* Function: error 00041 * Report a fatal runtime error 00042 * 00043 * Outputs the specified error message to stderr so it will appear via the USB 00044 * serial port, and then calls exit(1) to die with the blue lights of death. 00045 * 00046 * Variables: 00047 * format - printf-style format string, followed by associated variables 00048 */ 00049 void error(const char* format, ...); 00050 #endif 00051 00052 #include <stdlib.h> 00053 00054 #ifdef NDEBUG 00055 #define error(...) (exit(1)) 00056 #else 00057 #include <stdio.h> 00058 #define error(...) (fprintf(stderr, __VA_ARGS__), exit(1)) 00059 #endif 00060 00061 #endif
Generated on Thu Dec 15 2022 06:07:04 by 1.7.2