libuav original

Dependents:   UAVCAN UAVCAN_Subscriber

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers debug.hpp Source File

debug.hpp

00001 /*
00002  * Debug stuff, should only be used for library development.
00003  * Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
00004  */
00005 
00006 #ifndef UAVCAN_DEBUG_HPP_INCLUDED
00007 #define UAVCAN_DEBUG_HPP_INCLUDED
00008 
00009 #include <uavcan/build_config.hpp>
00010 
00011 #if UAVCAN_DEBUG
00012 
00013 # include <cstdio>
00014 # include <cstdarg>
00015 
00016 # if __GNUC__
00017 __attribute__ ((format(printf, 2, 3)))
00018 # endif
00019 static void UAVCAN_TRACE(const char* src, const char* fmt, ...)
00020 {
00021     va_list args;
00022     (void)std::printf("UAVCAN: %s: ", src);
00023     va_start(args, fmt);
00024     (void)std::vprintf(fmt, args);
00025     va_end(args);
00026     (void)std::puts("");
00027 }
00028 
00029 #else
00030 
00031 # define UAVCAN_TRACE(...) ((void)0)
00032 
00033 #endif
00034 
00035 #endif // UAVCAN_DEBUG_HPP_INCLUDED