BLE temperature profile using digital DS1820 or analog LM35 sensors
mbed/error.h@0:637031152314, 2015-03-07 (annotated)
- Committer:
- gkroussos
- Date:
- Sat Mar 07 16:23:41 2015 +0000
- Revision:
- 0:637031152314
Working version 1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gkroussos | 0:637031152314 | 1 | /* mbed Microcontroller Library |
gkroussos | 0:637031152314 | 2 | * Copyright (c) 2006-2013 ARM Limited |
gkroussos | 0:637031152314 | 3 | * |
gkroussos | 0:637031152314 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
gkroussos | 0:637031152314 | 5 | * you may not use this file except in compliance with the License. |
gkroussos | 0:637031152314 | 6 | * You may obtain a copy of the License at |
gkroussos | 0:637031152314 | 7 | * |
gkroussos | 0:637031152314 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
gkroussos | 0:637031152314 | 9 | * |
gkroussos | 0:637031152314 | 10 | * Unless required by applicable law or agreed to in writing, software |
gkroussos | 0:637031152314 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
gkroussos | 0:637031152314 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
gkroussos | 0:637031152314 | 13 | * See the License for the specific language governing permissions and |
gkroussos | 0:637031152314 | 14 | * limitations under the License. |
gkroussos | 0:637031152314 | 15 | */ |
gkroussos | 0:637031152314 | 16 | #ifndef MBED_ERROR_H |
gkroussos | 0:637031152314 | 17 | #define MBED_ERROR_H |
gkroussos | 0:637031152314 | 18 | |
gkroussos | 0:637031152314 | 19 | /** To generate a fatal compile-time error, you can use the pre-processor #error directive. |
gkroussos | 0:637031152314 | 20 | * |
gkroussos | 0:637031152314 | 21 | * @code |
gkroussos | 0:637031152314 | 22 | * #error "That shouldn't have happened!" |
gkroussos | 0:637031152314 | 23 | * @endcode |
gkroussos | 0:637031152314 | 24 | * |
gkroussos | 0:637031152314 | 25 | * If the compiler evaluates this line, it will report the error and stop the compile. |
gkroussos | 0:637031152314 | 26 | * |
gkroussos | 0:637031152314 | 27 | * For example, you could use this to check some user-defined compile-time variables: |
gkroussos | 0:637031152314 | 28 | * |
gkroussos | 0:637031152314 | 29 | * @code |
gkroussos | 0:637031152314 | 30 | * #define NUM_PORTS 7 |
gkroussos | 0:637031152314 | 31 | * #if (NUM_PORTS > 4) |
gkroussos | 0:637031152314 | 32 | * #error "NUM_PORTS must be less than 4" |
gkroussos | 0:637031152314 | 33 | * #endif |
gkroussos | 0:637031152314 | 34 | * @endcode |
gkroussos | 0:637031152314 | 35 | * |
gkroussos | 0:637031152314 | 36 | * Reporting Run-Time Errors: |
gkroussos | 0:637031152314 | 37 | * To generate a fatal run-time error, you can use the mbed error() function. |
gkroussos | 0:637031152314 | 38 | * |
gkroussos | 0:637031152314 | 39 | * @code |
gkroussos | 0:637031152314 | 40 | * error("That shouldn't have happened!"); |
gkroussos | 0:637031152314 | 41 | * @endcode |
gkroussos | 0:637031152314 | 42 | * |
gkroussos | 0:637031152314 | 43 | * If the mbed running the program executes this function, it will print the |
gkroussos | 0:637031152314 | 44 | * message via the USB serial port, and then die with the blue lights of death! |
gkroussos | 0:637031152314 | 45 | * |
gkroussos | 0:637031152314 | 46 | * The message can use printf-style formatting, so you can report variables in the |
gkroussos | 0:637031152314 | 47 | * message too. For example, you could use this to check a run-time condition: |
gkroussos | 0:637031152314 | 48 | * |
gkroussos | 0:637031152314 | 49 | * @code |
gkroussos | 0:637031152314 | 50 | * if(x >= 5) { |
gkroussos | 0:637031152314 | 51 | * error("expected x to be less than 5, but got %d", x); |
gkroussos | 0:637031152314 | 52 | * } |
gkroussos | 0:637031152314 | 53 | * #endcode |
gkroussos | 0:637031152314 | 54 | */ |
gkroussos | 0:637031152314 | 55 | |
gkroussos | 0:637031152314 | 56 | #include <stdlib.h> |
gkroussos | 0:637031152314 | 57 | #include "device.h" |
gkroussos | 0:637031152314 | 58 | |
gkroussos | 0:637031152314 | 59 | #if DEVICE_STDIO_MESSAGES |
gkroussos | 0:637031152314 | 60 | #include <stdio.h> |
gkroussos | 0:637031152314 | 61 | #define error(...) (fprintf(stderr, __VA_ARGS__), exit(1)) |
gkroussos | 0:637031152314 | 62 | #else |
gkroussos | 0:637031152314 | 63 | #define error(...) (exit(1)) |
gkroussos | 0:637031152314 | 64 | #endif |
gkroussos | 0:637031152314 | 65 | |
gkroussos | 0:637031152314 | 66 | #endif |