Sebastián Pastor / EtheriosCloudConnector
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers connector_debug.h Source File

connector_debug.h

00001 /*
00002  * Copyright (c) 2013 Digi International Inc.,
00003  * All rights not expressly granted are reserved.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
00007  * You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
00010  * =======================================================================
00011  */
00012 #ifndef CONNECTOR_DEBUG_H_
00013 #define CONNECTOR_DEBUG_H_
00014 
00015 #include "connector_config.h"
00016 
00017 #if (defined CONNECTOR_DEBUG)
00018 /**
00019  * Debug output from Cloud Connector, Writes a formatted string to stdout, expanding the format
00020  * tags with the value of the argument list arg.  This function behaves exactly as
00021  * printf except that the variable argument list is passed as a va_list instead of a
00022  * succession of arguments.
00023  *
00024  * In the C library the prototype for vprintf is defined as vprintf(const char *format, va_list ap);
00025  *
00026  */
00027 void connector_debug_printf(char const * const format, ...);
00028 
00029 /**
00030 * @defgroup DEBUG_MACROS User Defined Debug Macros
00031 * @{
00032 */
00033 /**
00034  *  Verify that the condition is true, otherwise halt the program.
00035  */
00036 #define ASSERT(cond)        assert(cond)
00037 /**
00038 * @}
00039 */
00040 
00041 #else
00042 
00043 #define ASSERT(cond)
00044 #endif
00045 
00046 /**
00047  * Compile time assertion of functional state (limits, range checking, etc.)
00048  *
00049  *   Failure will emit a compiler-specific error
00050  *           gcc: 'duplicate case value'
00051  *   Example:
00052  *           CONFIRM(sizeof (int) == 4);
00053  *           CONFIRM(CHAR_BIT == 8);
00054  *           CONFIRM(ElementCount(array) == array_item_count);
00055  */
00056 #define CONFIRM(cond)           do { switch(0) {case 0: case (cond):;} } while (0)
00057 
00058 
00059 #endif
00060