meh
Fork of mbed by
Embed:
(wiki syntax)
Show/hide line numbers
mbed_error.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_ERROR_H 00017 #define MBED_ERROR_H 00018 00019 /** To generate a fatal compile-time error, you can use the pre-processor #error directive. 00020 * 00021 * @code 00022 * #error "That shouldn't have happened!" 00023 * @endcode 00024 * 00025 * If the compiler evaluates this line, it will report the error and stop the compile. 00026 * 00027 * For example, you could use this to check some user-defined compile-time variables: 00028 * 00029 * @code 00030 * #define NUM_PORTS 7 00031 * #if (NUM_PORTS > 4) 00032 * #error "NUM_PORTS must be less than 4" 00033 * #endif 00034 * @endcode 00035 * 00036 * Reporting Run-Time Errors: 00037 * To generate a fatal run-time error, you can use the mbed error() function. 00038 * 00039 * @code 00040 * error("That shouldn't have happened!"); 00041 * @endcode 00042 * 00043 * If the mbed running the program executes this function, it will print the 00044 * message via the USB serial port, and then die with the blue lights of death! 00045 * 00046 * The message can use printf-style formatting, so you can report variables in the 00047 * message too. For example, you could use this to check a run-time condition: 00048 * 00049 * @code 00050 * if(x >= 5) { 00051 * error("expected x to be less than 5, but got %d", x); 00052 * } 00053 * #endcode 00054 */ 00055 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 00060 void error(const char* format, ...); 00061 00062 #ifdef __cplusplus 00063 } 00064 #endif 00065 00066 #endif
Generated on Wed Jul 13 2022 07:02:15 by 1.7.2