Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_debug.h Source File

mbed_debug.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef MBED_DEBUG_H
00018 #define MBED_DEBUG_H
00019 #if DEVICE_STDIO_MESSAGES
00020 #include <stdio.h>
00021 #include <stdarg.h>
00022 #endif
00023 #include "platform/mbed_toolchain.h"
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /** \addtogroup platform-public-api */
00030 /** @{*/
00031 
00032 /**
00033  * \defgroup platform_debug Debug functions
00034  * @{
00035  */
00036 
00037 static inline void debug(const char *format, ...) MBED_PRINTF(1, 2);
00038 static inline void debug_if(int condition, const char *format, ...) MBED_PRINTF(2, 3);
00039 
00040 /** Output a debug message
00041  *
00042  * @param format printf-style format string, followed by variables
00043  */
00044 static inline void debug(const char *format, ...)
00045 {
00046 #if DEVICE_STDIO_MESSAGES && !defined(NDEBUG)
00047     va_list args;
00048     va_start(args, format);
00049     vfprintf(stderr, format, args);
00050     va_end(args);
00051 #endif
00052 }
00053 
00054 
00055 /** Conditionally output a debug message
00056  *
00057  * NOTE: If the condition is constant false (== 0) and the compiler optimization
00058  * level is greater than 0, then the whole function will be compiled away.
00059  *
00060  * @param condition output only if condition is true (!= 0)
00061  * @param format printf-style format string, followed by variables
00062  */
00063 static inline void debug_if(int condition, const char *format, ...)
00064 {
00065 #if DEVICE_STDIO_MESSAGES && !defined(NDEBUG)
00066     if (condition) {
00067         va_list args;
00068         va_start(args, format);
00069         vfprintf(stderr, format, args);
00070         va_end(args);
00071     }
00072 #endif
00073 }
00074 
00075 
00076 #ifdef __cplusplus
00077 }
00078 #endif
00079 
00080 #endif
00081 
00082 /**@}*/
00083 
00084 /**@}*/
00085