initial

Dependencies:   mbed

Committer:
yihui
Date:
Mon Jan 11 02:32:24 2016 +0000
Revision:
0:638edba3adf6
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 0:638edba3adf6 1 /* mbed Microcontroller Library
yihui 0:638edba3adf6 2 * Copyright (c) 2006-2013 ARM Limited
yihui 0:638edba3adf6 3 *
yihui 0:638edba3adf6 4 * Licensed under the Apache License, Version 2.0 (the "License");
yihui 0:638edba3adf6 5 * you may not use this file except in compliance with the License.
yihui 0:638edba3adf6 6 * You may obtain a copy of the License at
yihui 0:638edba3adf6 7 *
yihui 0:638edba3adf6 8 * http://www.apache.org/licenses/LICENSE-2.0
yihui 0:638edba3adf6 9 *
yihui 0:638edba3adf6 10 * Unless required by applicable law or agreed to in writing, software
yihui 0:638edba3adf6 11 * distributed under the License is distributed on an "AS IS" BASIS,
yihui 0:638edba3adf6 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
yihui 0:638edba3adf6 13 * See the License for the specific language governing permissions and
yihui 0:638edba3adf6 14 * limitations under the License.
yihui 0:638edba3adf6 15 */
yihui 0:638edba3adf6 16 #ifndef MBED_ASSERT_H
yihui 0:638edba3adf6 17 #define MBED_ASSERT_H
yihui 0:638edba3adf6 18
yihui 0:638edba3adf6 19 #ifdef __cplusplus
yihui 0:638edba3adf6 20 extern "C" {
yihui 0:638edba3adf6 21 #endif
yihui 0:638edba3adf6 22
yihui 0:638edba3adf6 23 /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
yihui 0:638edba3adf6 24 * This function is active only if NDEBUG is not defined prior to including this
yihui 0:638edba3adf6 25 * assert header file.
yihui 0:638edba3adf6 26 * In case of MBED_ASSERT failing condition, error() is called with the assertation message.
yihui 0:638edba3adf6 27 * @param expr Expresion to be checked.
yihui 0:638edba3adf6 28 * @param file File where assertation failed.
yihui 0:638edba3adf6 29 * @param line Failing assertation line number.
yihui 0:638edba3adf6 30 */
yihui 0:638edba3adf6 31 void mbed_assert_internal(const char *expr, const char *file, int line);
yihui 0:638edba3adf6 32
yihui 0:638edba3adf6 33 #ifdef __cplusplus
yihui 0:638edba3adf6 34 }
yihui 0:638edba3adf6 35 #endif
yihui 0:638edba3adf6 36
yihui 0:638edba3adf6 37 #ifdef NDEBUG
yihui 0:638edba3adf6 38 #define MBED_ASSERT(expr) ((void)0)
yihui 0:638edba3adf6 39
yihui 0:638edba3adf6 40 #else
yihui 0:638edba3adf6 41 #define MBED_ASSERT(expr) \
yihui 0:638edba3adf6 42 do { \
yihui 0:638edba3adf6 43 if (!(expr)) { \
yihui 0:638edba3adf6 44 mbed_assert_internal(#expr, __FILE__, __LINE__); \
yihui 0:638edba3adf6 45 } \
yihui 0:638edba3adf6 46 } while (0)
yihui 0:638edba3adf6 47 #endif
yihui 0:638edba3adf6 48
yihui 0:638edba3adf6 49 #endif