test

Committer:
elijahsj
Date:
Mon Nov 09 00:33:19 2020 -0500
Revision:
2:4364577b5ad8
Parent:
1:8a094db1347f
copied mbed library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elijahsj 1:8a094db1347f 1
elijahsj 1:8a094db1347f 2 /** \addtogroup platform */
elijahsj 1:8a094db1347f 3 /** @{*/
elijahsj 1:8a094db1347f 4 /* mbed Microcontroller Library
elijahsj 1:8a094db1347f 5 * Copyright (c) 2006-2013 ARM Limited
elijahsj 1:8a094db1347f 6 *
elijahsj 1:8a094db1347f 7 * Licensed under the Apache License, Version 2.0 (the "License");
elijahsj 1:8a094db1347f 8 * you may not use this file except in compliance with the License.
elijahsj 1:8a094db1347f 9 * You may obtain a copy of the License at
elijahsj 1:8a094db1347f 10 *
elijahsj 1:8a094db1347f 11 * http://www.apache.org/licenses/LICENSE-2.0
elijahsj 1:8a094db1347f 12 *
elijahsj 1:8a094db1347f 13 * Unless required by applicable law or agreed to in writing, software
elijahsj 1:8a094db1347f 14 * distributed under the License is distributed on an "AS IS" BASIS,
elijahsj 1:8a094db1347f 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
elijahsj 1:8a094db1347f 16 * See the License for the specific language governing permissions and
elijahsj 1:8a094db1347f 17 * limitations under the License.
elijahsj 1:8a094db1347f 18 */
elijahsj 1:8a094db1347f 19 #ifndef MBED_ERROR_H
elijahsj 1:8a094db1347f 20 #define MBED_ERROR_H
elijahsj 1:8a094db1347f 21
elijahsj 1:8a094db1347f 22
elijahsj 1:8a094db1347f 23
elijahsj 1:8a094db1347f 24 /** To generate a fatal compile-time error, you can use the pre-processor #error directive.
elijahsj 1:8a094db1347f 25 *
elijahsj 1:8a094db1347f 26 * @param format C string that contains data stream to be printed.
elijahsj 1:8a094db1347f 27 * Code snippets below show valid format.
elijahsj 1:8a094db1347f 28 *
elijahsj 1:8a094db1347f 29 * @code
elijahsj 1:8a094db1347f 30 * #error "That shouldn't have happened!"
elijahsj 1:8a094db1347f 31 * @endcode
elijahsj 1:8a094db1347f 32 *
elijahsj 1:8a094db1347f 33 * If the compiler evaluates this line, it will report the error and stop the compile.
elijahsj 1:8a094db1347f 34 *
elijahsj 1:8a094db1347f 35 * For example, you could use this to check some user-defined compile-time variables:
elijahsj 1:8a094db1347f 36 *
elijahsj 1:8a094db1347f 37 * @code
elijahsj 1:8a094db1347f 38 * #define NUM_PORTS 7
elijahsj 1:8a094db1347f 39 * #if (NUM_PORTS > 4)
elijahsj 1:8a094db1347f 40 * #error "NUM_PORTS must be less than 4"
elijahsj 1:8a094db1347f 41 * #endif
elijahsj 1:8a094db1347f 42 * @endcode
elijahsj 1:8a094db1347f 43 *
elijahsj 1:8a094db1347f 44 * Reporting Run-Time Errors:
elijahsj 1:8a094db1347f 45 * To generate a fatal run-time error, you can use the mbed error() function.
elijahsj 1:8a094db1347f 46 *
elijahsj 1:8a094db1347f 47 * @code
elijahsj 1:8a094db1347f 48 * error("That shouldn't have happened!");
elijahsj 1:8a094db1347f 49 * @endcode
elijahsj 1:8a094db1347f 50 *
elijahsj 1:8a094db1347f 51 * If the mbed running the program executes this function, it will print the
elijahsj 1:8a094db1347f 52 * message via the USB serial port, and then die with the blue lights of death!
elijahsj 1:8a094db1347f 53 *
elijahsj 1:8a094db1347f 54 * The message can use printf-style formatting, so you can report variables in the
elijahsj 1:8a094db1347f 55 * message too. For example, you could use this to check a run-time condition:
elijahsj 1:8a094db1347f 56 *
elijahsj 1:8a094db1347f 57 * @code
elijahsj 1:8a094db1347f 58 * if(x >= 5) {
elijahsj 1:8a094db1347f 59 * error("expected x to be less than 5, but got %d", x);
elijahsj 1:8a094db1347f 60 * }
elijahsj 1:8a094db1347f 61 * @endcode
elijahsj 1:8a094db1347f 62 *
elijahsj 1:8a094db1347f 63 *
elijahsj 1:8a094db1347f 64 */
elijahsj 1:8a094db1347f 65
elijahsj 1:8a094db1347f 66 #ifdef __cplusplus
elijahsj 1:8a094db1347f 67 extern "C" {
elijahsj 1:8a094db1347f 68 #endif
elijahsj 1:8a094db1347f 69 void error(const char* format, ...);
elijahsj 1:8a094db1347f 70
elijahsj 1:8a094db1347f 71 #ifdef __cplusplus
elijahsj 1:8a094db1347f 72 }
elijahsj 1:8a094db1347f 73 #endif
elijahsj 1:8a094db1347f 74
elijahsj 1:8a094db1347f 75 #endif
elijahsj 1:8a094db1347f 76
elijahsj 1:8a094db1347f 77 /** @}*/