,,

Fork of Application by Daniel Sygut

Committer:
Zaitsev
Date:
Thu Feb 15 14:29:23 2018 +0000
Revision:
15:2a20c3d2616e
Parent:
10:41552d038a69
j

Who changed what in which revision?

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