]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/api/mbed_error.h
1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 /** To generate a fatal compile-time error, you can use the pre-processor #error directive.
22 * #error "That shouldn't have happened!"
25 * If the compiler evaluates this line, it will report the error and stop the compile.
27 * For example, you could use this to check some user-defined compile-time variables:
32 * #error "NUM_PORTS must be less than 4"
36 * Reporting Run-Time Errors:
37 * To generate a fatal run-time error, you can use the mbed error() function.
40 * error("That shouldn't have happened!");
43 * If the mbed running the program executes this function, it will print the
44 * message via the USB serial port, and then die with the blue lights of death!
46 * The message can use printf-style formatting, so you can report variables in the
47 * message too. For example, you could use this to check a run-time condition:
51 * error("expected x to be less than 5, but got %d", x);
60 void error(const char* format
, ...);