mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
platform/mbed_error.h@181:57724642e740, 2018-02-16 (annotated)
- Committer:
- AnnaBridge
- Date:
- Fri Feb 16 16:09:33 2018 +0000
- Revision:
- 181:57724642e740
- Parent:
- 178:79309dc6340a
- Child:
- 186:707f6e361f3e
mbed-dev library. Release version 159.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 149:156823d33999 | 1 | |
<> | 149:156823d33999 | 2 | /** \addtogroup platform */ |
<> | 149:156823d33999 | 3 | /** @{*/ |
AnnaBridge | 178:79309dc6340a | 4 | /** |
AnnaBridge | 178:79309dc6340a | 5 | * \defgroup platform_error Error functions |
AnnaBridge | 178:79309dc6340a | 6 | * @{ |
AnnaBridge | 178:79309dc6340a | 7 | */ |
<> | 149:156823d33999 | 8 | /* mbed Microcontroller Library |
<> | 149:156823d33999 | 9 | * Copyright (c) 2006-2013 ARM Limited |
<> | 149:156823d33999 | 10 | * |
<> | 149:156823d33999 | 11 | * Licensed under the Apache License, Version 2.0 (the "License"); |
<> | 149:156823d33999 | 12 | * you may not use this file except in compliance with the License. |
<> | 149:156823d33999 | 13 | * You may obtain a copy of the License at |
<> | 149:156823d33999 | 14 | * |
<> | 149:156823d33999 | 15 | * http://www.apache.org/licenses/LICENSE-2.0 |
<> | 149:156823d33999 | 16 | * |
<> | 149:156823d33999 | 17 | * Unless required by applicable law or agreed to in writing, software |
<> | 149:156823d33999 | 18 | * distributed under the License is distributed on an "AS IS" BASIS, |
<> | 149:156823d33999 | 19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
<> | 149:156823d33999 | 20 | * See the License for the specific language governing permissions and |
<> | 149:156823d33999 | 21 | * limitations under the License. |
<> | 149:156823d33999 | 22 | */ |
<> | 149:156823d33999 | 23 | #ifndef MBED_ERROR_H |
<> | 149:156823d33999 | 24 | #define MBED_ERROR_H |
<> | 149:156823d33999 | 25 | |
AnnaBridge | 167:e84263d55307 | 26 | |
AnnaBridge | 167:e84263d55307 | 27 | |
<> | 149:156823d33999 | 28 | /** To generate a fatal compile-time error, you can use the pre-processor #error directive. |
<> | 149:156823d33999 | 29 | * |
AnnaBridge | 167:e84263d55307 | 30 | * @param format C string that contains data stream to be printed. |
AnnaBridge | 167:e84263d55307 | 31 | * Code snippets below show valid format. |
AnnaBridge | 167:e84263d55307 | 32 | * |
<> | 149:156823d33999 | 33 | * @code |
<> | 149:156823d33999 | 34 | * #error "That shouldn't have happened!" |
<> | 149:156823d33999 | 35 | * @endcode |
<> | 149:156823d33999 | 36 | * |
<> | 149:156823d33999 | 37 | * If the compiler evaluates this line, it will report the error and stop the compile. |
<> | 149:156823d33999 | 38 | * |
<> | 149:156823d33999 | 39 | * For example, you could use this to check some user-defined compile-time variables: |
<> | 149:156823d33999 | 40 | * |
<> | 149:156823d33999 | 41 | * @code |
<> | 149:156823d33999 | 42 | * #define NUM_PORTS 7 |
<> | 149:156823d33999 | 43 | * #if (NUM_PORTS > 4) |
<> | 149:156823d33999 | 44 | * #error "NUM_PORTS must be less than 4" |
<> | 149:156823d33999 | 45 | * #endif |
<> | 149:156823d33999 | 46 | * @endcode |
<> | 149:156823d33999 | 47 | * |
<> | 149:156823d33999 | 48 | * Reporting Run-Time Errors: |
<> | 149:156823d33999 | 49 | * To generate a fatal run-time error, you can use the mbed error() function. |
<> | 149:156823d33999 | 50 | * |
<> | 149:156823d33999 | 51 | * @code |
<> | 149:156823d33999 | 52 | * error("That shouldn't have happened!"); |
<> | 149:156823d33999 | 53 | * @endcode |
<> | 149:156823d33999 | 54 | * |
<> | 149:156823d33999 | 55 | * If the mbed running the program executes this function, it will print the |
<> | 149:156823d33999 | 56 | * message via the USB serial port, and then die with the blue lights of death! |
<> | 149:156823d33999 | 57 | * |
<> | 149:156823d33999 | 58 | * The message can use printf-style formatting, so you can report variables in the |
<> | 149:156823d33999 | 59 | * message too. For example, you could use this to check a run-time condition: |
<> | 149:156823d33999 | 60 | * |
<> | 149:156823d33999 | 61 | * @code |
<> | 149:156823d33999 | 62 | * if(x >= 5) { |
<> | 149:156823d33999 | 63 | * error("expected x to be less than 5, but got %d", x); |
<> | 149:156823d33999 | 64 | * } |
AnnaBridge | 167:e84263d55307 | 65 | * @endcode |
AnnaBridge | 167:e84263d55307 | 66 | * |
AnnaBridge | 167:e84263d55307 | 67 | * |
<> | 149:156823d33999 | 68 | */ |
<> | 149:156823d33999 | 69 | |
<> | 149:156823d33999 | 70 | #ifdef __cplusplus |
<> | 149:156823d33999 | 71 | extern "C" { |
<> | 149:156823d33999 | 72 | #endif |
<> | 149:156823d33999 | 73 | void error(const char* format, ...); |
<> | 149:156823d33999 | 74 | |
<> | 149:156823d33999 | 75 | #ifdef __cplusplus |
<> | 149:156823d33999 | 76 | } |
<> | 149:156823d33999 | 77 | #endif |
<> | 149:156823d33999 | 78 | |
<> | 149:156823d33999 | 79 | #endif |
<> | 149:156823d33999 | 80 | |
<> | 149:156823d33999 | 81 | /** @}*/ |
AnnaBridge | 178:79309dc6340a | 82 | /** @}*/ |