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