Forked version

Fork of mbed-dev-bin by Lancaster University

Committer:
cefn
Date:
Wed Jun 01 17:38:31 2016 +0000
Revision:
2:a715a02d198e
Parent:
0:e1a608bb55e8
Temporary microbit tree for shipping lifedetector (with minor patches as agreed with @jamesadevine

Who changed what in which revision?

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