temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IKobayashi 0:c88c3b616c00 1
IKobayashi 0:c88c3b616c00 2 /** \addtogroup platform */
IKobayashi 0:c88c3b616c00 3 /** @{*/
IKobayashi 0:c88c3b616c00 4 /* mbed Microcontroller Library
IKobayashi 0:c88c3b616c00 5 * Copyright (c) 2006-2013 ARM Limited
IKobayashi 0:c88c3b616c00 6 *
IKobayashi 0:c88c3b616c00 7 * Licensed under the Apache License, Version 2.0 (the "License");
IKobayashi 0:c88c3b616c00 8 * you may not use this file except in compliance with the License.
IKobayashi 0:c88c3b616c00 9 * You may obtain a copy of the License at
IKobayashi 0:c88c3b616c00 10 *
IKobayashi 0:c88c3b616c00 11 * http://www.apache.org/licenses/LICENSE-2.0
IKobayashi 0:c88c3b616c00 12 *
IKobayashi 0:c88c3b616c00 13 * Unless required by applicable law or agreed to in writing, software
IKobayashi 0:c88c3b616c00 14 * distributed under the License is distributed on an "AS IS" BASIS,
IKobayashi 0:c88c3b616c00 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
IKobayashi 0:c88c3b616c00 16 * See the License for the specific language governing permissions and
IKobayashi 0:c88c3b616c00 17 * limitations under the License.
IKobayashi 0:c88c3b616c00 18 */
IKobayashi 0:c88c3b616c00 19 #ifndef MBED_ASSERT_H
IKobayashi 0:c88c3b616c00 20 #define MBED_ASSERT_H
IKobayashi 0:c88c3b616c00 21
IKobayashi 0:c88c3b616c00 22 #include "mbed_preprocessor.h"
IKobayashi 0:c88c3b616c00 23
IKobayashi 0:c88c3b616c00 24 #ifdef __cplusplus
IKobayashi 0:c88c3b616c00 25 extern "C" {
IKobayashi 0:c88c3b616c00 26 #endif
IKobayashi 0:c88c3b616c00 27
IKobayashi 0:c88c3b616c00 28 /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
IKobayashi 0:c88c3b616c00 29 * This function is active only if NDEBUG is not defined prior to including this
IKobayashi 0:c88c3b616c00 30 * assert header file.
IKobayashi 0:c88c3b616c00 31 * In case of MBED_ASSERT failing condition, error() is called with the assertation message.
IKobayashi 0:c88c3b616c00 32 * @param expr Expresion to be checked.
IKobayashi 0:c88c3b616c00 33 * @param file File where assertation failed.
IKobayashi 0:c88c3b616c00 34 * @param line Failing assertation line number.
IKobayashi 0:c88c3b616c00 35 */
IKobayashi 0:c88c3b616c00 36 void mbed_assert_internal(const char *expr, const char *file, int line);
IKobayashi 0:c88c3b616c00 37
IKobayashi 0:c88c3b616c00 38 #ifdef __cplusplus
IKobayashi 0:c88c3b616c00 39 }
IKobayashi 0:c88c3b616c00 40 #endif
IKobayashi 0:c88c3b616c00 41
IKobayashi 0:c88c3b616c00 42 #ifdef NDEBUG
IKobayashi 0:c88c3b616c00 43 #define MBED_ASSERT(expr) ((void)0)
IKobayashi 0:c88c3b616c00 44
IKobayashi 0:c88c3b616c00 45 #else
IKobayashi 0:c88c3b616c00 46 #define MBED_ASSERT(expr) \
IKobayashi 0:c88c3b616c00 47 do { \
IKobayashi 0:c88c3b616c00 48 if (!(expr)) { \
IKobayashi 0:c88c3b616c00 49 mbed_assert_internal(#expr, __FILE__, __LINE__); \
IKobayashi 0:c88c3b616c00 50 } \
IKobayashi 0:c88c3b616c00 51 } while (0)
IKobayashi 0:c88c3b616c00 52 #endif
IKobayashi 0:c88c3b616c00 53
IKobayashi 0:c88c3b616c00 54
IKobayashi 0:c88c3b616c00 55 /** MBED_STATIC_ASSERT
IKobayashi 0:c88c3b616c00 56 * Declare compile-time assertions, results in compile-time error if condition is false
IKobayashi 0:c88c3b616c00 57 *
IKobayashi 0:c88c3b616c00 58 * The assertion acts as a declaration that can be placed at file scope, in a
IKobayashi 0:c88c3b616c00 59 * code block (except after a label), or as a member of a C++ class/struct/union.
IKobayashi 0:c88c3b616c00 60 *
IKobayashi 0:c88c3b616c00 61 * @note
IKobayashi 0:c88c3b616c00 62 * Use of MBED_STATIC_ASSERT as a member of a struct/union is limited:
IKobayashi 0:c88c3b616c00 63 * - In C++, MBED_STATIC_ASSERT is valid in class/struct/union scope.
IKobayashi 0:c88c3b616c00 64 * - In C, MBED_STATIC_ASSERT is not valid in struct/union scope, and
IKobayashi 0:c88c3b616c00 65 * MBED_STRUCT_STATIC_ASSERT is provided as an alternative that is valid
IKobayashi 0:c88c3b616c00 66 * in C and C++ class/struct/union scope.
IKobayashi 0:c88c3b616c00 67 *
IKobayashi 0:c88c3b616c00 68 * @code
IKobayashi 0:c88c3b616c00 69 * MBED_STATIC_ASSERT(MBED_LIBRARY_VERSION >= 120,
IKobayashi 0:c88c3b616c00 70 * "The mbed library must be at least version 120");
IKobayashi 0:c88c3b616c00 71 *
IKobayashi 0:c88c3b616c00 72 * int main() {
IKobayashi 0:c88c3b616c00 73 * MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
IKobayashi 0:c88c3b616c00 74 * "An int must be larger than a char");
IKobayashi 0:c88c3b616c00 75 * }
IKobayashi 0:c88c3b616c00 76 * @endcode
IKobayashi 0:c88c3b616c00 77 */
IKobayashi 0:c88c3b616c00 78 #if defined(__cplusplus) && (__cplusplus >= 201103L || __cpp_static_assert >= 200410L)
IKobayashi 0:c88c3b616c00 79 #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
IKobayashi 0:c88c3b616c00 80 #elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
IKobayashi 0:c88c3b616c00 81 #define MBED_STATIC_ASSERT(expr, msg) _Static_assert(expr, msg)
IKobayashi 0:c88c3b616c00 82 #elif defined(__cplusplus) && defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) \
IKobayashi 0:c88c3b616c00 83 && (__GNUC__*100 + __GNUC_MINOR__) > 403L
IKobayashi 0:c88c3b616c00 84 #define MBED_STATIC_ASSERT(expr, msg) __extension__ static_assert(expr, msg)
IKobayashi 0:c88c3b616c00 85 #elif !defined(__cplusplus) && defined(__GNUC__) && !defined(__CC_ARM) \
IKobayashi 0:c88c3b616c00 86 && (__GNUC__*100 + __GNUC_MINOR__) > 406L
IKobayashi 0:c88c3b616c00 87 #define MBED_STATIC_ASSERT(expr, msg) __extension__ _Static_assert(expr, msg)
IKobayashi 0:c88c3b616c00 88 #elif defined(__ICCARM__)
IKobayashi 0:c88c3b616c00 89 #define MBED_STATIC_ASSERT(expr, msg) static_assert(expr, msg)
IKobayashi 0:c88c3b616c00 90 #else
IKobayashi 0:c88c3b616c00 91 #define MBED_STATIC_ASSERT(expr, msg) \
IKobayashi 0:c88c3b616c00 92 enum {MBED_CONCAT(MBED_ASSERTION_AT_, __LINE__) = sizeof(char[(expr) ? 1 : -1])}
IKobayashi 0:c88c3b616c00 93 #endif
IKobayashi 0:c88c3b616c00 94
IKobayashi 0:c88c3b616c00 95 /** MBED_STRUCT_STATIC_ASSERT
IKobayashi 0:c88c3b616c00 96 * Declare compile-time assertions, results in compile-time error if condition is false
IKobayashi 0:c88c3b616c00 97 *
IKobayashi 0:c88c3b616c00 98 * Unlike MBED_STATIC_ASSERT, MBED_STRUCT_STATIC_ASSERT can and must be used
IKobayashi 0:c88c3b616c00 99 * as a member of a C/C++ class/struct/union.
IKobayashi 0:c88c3b616c00 100 *
IKobayashi 0:c88c3b616c00 101 * @code
IKobayashi 0:c88c3b616c00 102 * struct thing {
IKobayashi 0:c88c3b616c00 103 * MBED_STATIC_ASSERT(2 + 2 == 4,
IKobayashi 0:c88c3b616c00 104 * "Hopefully the universe is mathematically consistent");
IKobayashi 0:c88c3b616c00 105 * };
IKobayashi 0:c88c3b616c00 106 * @endcode
IKobayashi 0:c88c3b616c00 107 */
IKobayashi 0:c88c3b616c00 108 #define MBED_STRUCT_STATIC_ASSERT(expr, msg) int : (expr) ? 0 : -1
IKobayashi 0:c88c3b616c00 109
IKobayashi 0:c88c3b616c00 110
IKobayashi 0:c88c3b616c00 111 #endif
IKobayashi 0:c88c3b616c00 112
IKobayashi 0:c88c3b616c00 113 /** @}*/