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