Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
mbed_debug.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_DEBUG_H 00017 #define MBED_DEBUG_H 00018 #include "device.h" 00019 00020 #ifdef __cplusplus 00021 extern "C" { 00022 #endif 00023 00024 #if DEVICE_STDIO_MESSAGES 00025 #include <stdio.h> 00026 #include <stdarg.h> 00027 00028 /** Output a debug message 00029 * 00030 * @param format printf-style format string, followed by variables 00031 */ 00032 static inline void debug(const char *format, ...) { 00033 va_list args; 00034 va_start(args, format); 00035 vfprintf(stderr, format, args); 00036 va_end(args); 00037 } 00038 00039 /** Conditionally output a debug message 00040 * 00041 * NOTE: If the condition is constant false (!= 1) and the compiler optimization 00042 * level is greater than 0, then the whole function will be compiled away. 00043 * 00044 * @param condition output only if condition is true (== 1) 00045 * @param format printf-style format string, followed by variables 00046 */ 00047 static inline void debug_if(int condition, const char *format, ...) { 00048 if (condition == 1) { 00049 va_list args; 00050 va_start(args, format); 00051 vfprintf(stderr, format, args); 00052 va_end(args); 00053 } 00054 } 00055 00056 #else 00057 static inline void debug(const char *format, ...) {} 00058 static inline void debug_if(int condition, const char *format, ...) {} 00059 00060 #endif 00061 00062 #ifdef __cplusplus 00063 } 00064 #endif 00065 00066 #endif
Generated on Tue Jul 12 2022 21:21:33 by
