code de start qui marche a la fin du premier match, base pour la suite
Fork of CRAC-Strat_2017_homologation_petit_rob by
mbed/error.h@0:ad97421fb1fb, 2016-04-13 (annotated)
- Committer:
- antbig
- Date:
- Wed Apr 13 22:04:54 2016 +0000
- Revision:
- 0:ad97421fb1fb
Ajout interruption fin de match
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
antbig | 0:ad97421fb1fb | 1 | /* mbed Microcontroller Library - error |
antbig | 0:ad97421fb1fb | 2 | * Copyright (c) 2006-2009 ARM Limited. All rights reserved. |
antbig | 0:ad97421fb1fb | 3 | */ |
antbig | 0:ad97421fb1fb | 4 | |
antbig | 0:ad97421fb1fb | 5 | #ifndef MBED_ERROR_H |
antbig | 0:ad97421fb1fb | 6 | #define MBED_ERROR_H |
antbig | 0:ad97421fb1fb | 7 | |
antbig | 0:ad97421fb1fb | 8 | /* Reporting Compile-Time Errors: |
antbig | 0:ad97421fb1fb | 9 | * To generate a fatal compile-time error, you can use the pre-processor #error directive. |
antbig | 0:ad97421fb1fb | 10 | * |
antbig | 0:ad97421fb1fb | 11 | * > #error "That shouldn't have happened!" |
antbig | 0:ad97421fb1fb | 12 | * |
antbig | 0:ad97421fb1fb | 13 | * If the compiler evaluates this line, it will report the error and stop the compile. |
antbig | 0:ad97421fb1fb | 14 | * |
antbig | 0:ad97421fb1fb | 15 | * For example, you could use this to check some user-defined compile-time variables: |
antbig | 0:ad97421fb1fb | 16 | * |
antbig | 0:ad97421fb1fb | 17 | * > #define NUM_PORTS 7 |
antbig | 0:ad97421fb1fb | 18 | * > #if (NUM_PORTS > 4) |
antbig | 0:ad97421fb1fb | 19 | * > #error "NUM_PORTS must be less than 4" |
antbig | 0:ad97421fb1fb | 20 | * > #endif |
antbig | 0:ad97421fb1fb | 21 | * |
antbig | 0:ad97421fb1fb | 22 | * Reporting Run-Time Errors: |
antbig | 0:ad97421fb1fb | 23 | * To generate a fatal run-time error, you can use the mbed error() function. |
antbig | 0:ad97421fb1fb | 24 | * |
antbig | 0:ad97421fb1fb | 25 | * > error("That shouldn't have happened!"); |
antbig | 0:ad97421fb1fb | 26 | * |
antbig | 0:ad97421fb1fb | 27 | * If the mbed running the program executes this function, it will print the |
antbig | 0:ad97421fb1fb | 28 | * message via the USB serial port, and then die with the blue lights of death! |
antbig | 0:ad97421fb1fb | 29 | * |
antbig | 0:ad97421fb1fb | 30 | * The message can use printf-style formatting, so you can report variables in the |
antbig | 0:ad97421fb1fb | 31 | * message too. For example, you could use this to check a run-time condition: |
antbig | 0:ad97421fb1fb | 32 | * |
antbig | 0:ad97421fb1fb | 33 | * > if(x >= 5) { |
antbig | 0:ad97421fb1fb | 34 | * > error("expected x to be less than 5, but got %d", x); |
antbig | 0:ad97421fb1fb | 35 | * > } |
antbig | 0:ad97421fb1fb | 36 | */ |
antbig | 0:ad97421fb1fb | 37 | |
antbig | 0:ad97421fb1fb | 38 | #if 0 // for documentation only |
antbig | 0:ad97421fb1fb | 39 | /* Function: error |
antbig | 0:ad97421fb1fb | 40 | * Report a fatal runtime error |
antbig | 0:ad97421fb1fb | 41 | * |
antbig | 0:ad97421fb1fb | 42 | * Outputs the specified error message to stderr so it will appear via the USB |
antbig | 0:ad97421fb1fb | 43 | * serial port, and then calls exit(1) to die with the blue lights of death. |
antbig | 0:ad97421fb1fb | 44 | * |
antbig | 0:ad97421fb1fb | 45 | * Variables: |
antbig | 0:ad97421fb1fb | 46 | * format - printf-style format string, followed by associated variables |
antbig | 0:ad97421fb1fb | 47 | */ |
antbig | 0:ad97421fb1fb | 48 | void error(const char* format, ...); |
antbig | 0:ad97421fb1fb | 49 | #endif |
antbig | 0:ad97421fb1fb | 50 | |
antbig | 0:ad97421fb1fb | 51 | #include <stdlib.h> |
antbig | 0:ad97421fb1fb | 52 | |
antbig | 0:ad97421fb1fb | 53 | #ifdef NDEBUG |
antbig | 0:ad97421fb1fb | 54 | #define error(...) (exit(1)) |
antbig | 0:ad97421fb1fb | 55 | #else |
antbig | 0:ad97421fb1fb | 56 | #include <stdio.h> |
antbig | 0:ad97421fb1fb | 57 | #define error(...) (fprintf(stderr, __VA_ARGS__), exit(1)) |
antbig | 0:ad97421fb1fb | 58 | #endif |
antbig | 0:ad97421fb1fb | 59 | |
antbig | 0:ad97421fb1fb | 60 | #endif |