DLT_CSTRING implementation non verbose mode.
[profile/ivi/dlt-daemon.git] / include / dlt / dlt_user_macros.h
old mode 100755 (executable)
new mode 100644 (file)
index 78ef66d..37a8ccf
@@ -1,75 +1,59 @@
-/*
- * Dlt- Diagnostic Log and Trace console apps
+/**
  * @licence app begin@
+ * Copyright (C) 2012  BMW AG
+ *
+ * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
+ *
+ * Contributions are licensed to the GENIVI Alliance under one or more
+ * Contribution License Agreements.
  *
- * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de>
- * 
- * This program is free software; you can redistribute it and/or modify it under the terms of the 
- * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
- * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 
- * Public License, version 2.1, for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public License, version 2.1, along 
- * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
- * 
- * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may 
- * also be applicable to programs even in cases in which the program is not a library in the technical sense.
- * 
- * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may 
- * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to 
- * license your linked modules under the GNU Lesser General Public License, version 2.1, you 
- * may use the program under the following exception.
- * 
- * As a special exception, the copyright holders of DLT give you permission to combine DLT 
- * with software programs or libraries that are released under any license unless such a combination is not
- * permitted by the license of such a software program or library. You may copy and distribute such a 
- * system following the terms of the GNU Lesser General Public License, version 2.1, including this
- * special exception, for DLT and the licenses of the other code concerned.
- * 
- * Note that people who make modified versions of DLT are not obligated to grant this special exception 
- * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, 
- * version 2.1, gives permission to release a modified version without this exception; this exception 
- * also makes it possible to release a modified version which carries forward this exception.
+ * \copyright
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
+ * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
+ *
+ * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de> BMW 2011-2012
+ *
+ * \file dlt_user_macros.h
+ * For further information see http://www.genivi.org/.
  * @licence end@
  */
 
-
 /*******************************************************************************
-**                                                                            **
-**  SRC-MODULE: dlt_user_macros.h                                             **
-**                                                                            **
-**  TARGET    : linux                                                         **
-**                                                                            **
-**  PROJECT   : DLT                                                           **
-**                                                                            **
-**  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
-**              Markus Klein                                                  **
-**                                                                            **
-**  PURPOSE   :                                                               **
-**                                                                            **
-**  REMARKS   :                                                               **
-**                                                                            **
-**  PLATFORM DEPENDANT [yes/no]: yes                                          **
-**                                                                            **
-**  TO BE CHANGED BY USER [yes/no]: no                                        **
-**                                                                            **
-*******************************************************************************/
+ **                                                                            **
+ **  SRC-MODULE: dlt_user_macros.h                                             **
+ **                                                                            **
+ **  TARGET    : linux                                                         **
+ **                                                                            **
+ **  PROJECT   : DLT                                                           **
+ **                                                                            **
+ **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+ **              Markus Klein                                                  **
+ **                                                                            **
+ **  PURPOSE   :                                                               **
+ **                                                                            **
+ **  REMARKS   :                                                               **
+ **                                                                            **
+ **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+ **                                                                            **
+ **  TO BE CHANGED BY USER [yes/no]: no                                        **
+ **                                                                            **
+ *******************************************************************************/
 
 /*******************************************************************************
-**                      Author Identity                                       **
-********************************************************************************
-**                                                                            **
-** Initials     Name                       Company                            **
-** --------     -------------------------  ---------------------------------- **
-**  aw          Alexander Wenzel           BMW                                **
-**  mk          Markus Klein               Fraunhofer ESK                     **
-*******************************************************************************/
+ **                      Author Identity                                       **
+ ********************************************************************************
+ **                                                                            **
+ ** Initials     Name                       Company                            **
+ ** --------     -------------------------  ---------------------------------- **
+ **  aw          Alexander Wenzel           BMW                                **
+ **  mk          Markus Klein               Fraunhofer ESK                     **
+ *******************************************************************************/
 
 /*******************************************************************************
-**                      Revision Control History                              **
-*******************************************************************************/
+ **                      Revision Control History                              **
+ *******************************************************************************/
 
 /*
  * $LastChangedRevision: 1515 $
 #ifndef DLT_USER_MACROS_H
 #define DLT_USER_MACORS_H
 
+#include "dlt_version.h"
+
 /**
 \defgroup userapi DLT User API
 \addtogroup userapi
 \{
-*/
+ \defgroup userapi DLT User API
+ \addtogroup userapi
+ \{
+ */
 
 /**************************************************************************************************
-* The folowing macros define a macro interface for DLT
-**************************************************************************************************/
+ * The folowing macros define a macro interface for DLT
+ **************************************************************************************************/
 
 /**
  * Create an object for a new context.
@@ -113,14 +99,16 @@ extern DltContext CONTEXT;
  * @param APPID application id with maximal four characters
  * @param DESCRIPTION ASCII string containing description
  */
-#define DLT_REGISTER_APP(APPID,DESCRIPTION) \
-    dlt_register_app( APPID, DESCRIPTION);
+#define DLT_REGISTER_APP(APPID,DESCRIPTION) do {\
+               dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION ); \
+               dlt_register_app( APPID, DESCRIPTION);} while(0)
+
 
 /**
  * Unregister application.
  */
-#define DLT_UNREGISTER_APP() \
-       dlt_unregister_app();
+#define DLT_UNREGISTER_APP() do{\
+       dlt_unregister_app();} while(0)
 
 /**
  * Register context (with default log level and default trace status)
@@ -128,8 +116,8 @@ extern DltContext CONTEXT;
  * @param CONTEXTID context id with maximal four characters
  * @param DESCRIPTION ASCII string containing description
  */
-#define DLT_REGISTER_CONTEXT(CONTEXT,CONTEXTID,DESCRIPTION) \
-       dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION);
+#define DLT_REGISTER_CONTEXT(CONTEXT,CONTEXTID,DESCRIPTION) do{\
+       dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION);} while(0)
 
 /**
  * Register context with pre-defined log level and pre-defined trace status.
@@ -137,19 +125,19 @@ extern DltContext CONTEXT;
  * @param CONTEXTID context id with maximal four characters
  * @param DESCRIPTION ASCII string containing description
  * @param LOGLEVEL log level to be pre-set for this context
         (DLT_LOG_DEFAULT is not allowed here)
+ (DLT_LOG_DEFAULT is not allowed here)
  * @param TRACESTATUS trace status to be pre-set for this context
                (DLT_TRACE_STATUS_DEFAULT is not allowed here)
+ (DLT_TRACE_STATUS_DEFAULT is not allowed here)
  */
-#define DLT_REGISTER_CONTEXT_LL_TS(CONTEXT,CONTEXTID,DESCRIPTION,LOGLEVEL,TRACESTATUS) \
-       dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS);
+#define DLT_REGISTER_CONTEXT_LL_TS(CONTEXT,CONTEXTID,DESCRIPTION,LOGLEVEL,TRACESTATUS) do{\
+       dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS);} while(0)
 
 /**
  * Unregister context.
  * @param CONTEXT object containing information about one special logging context
  */
-#define DLT_UNREGISTER_CONTEXT(CONTEXT) \
-       dlt_unregister_context(&(CONTEXT));
+#define DLT_UNREGISTER_CONTEXT(CONTEXT) do{\
+       dlt_unregister_context(&(CONTEXT));} while(0)
 
 /**
  * Register callback function called when injection message was received
@@ -157,8 +145,8 @@ extern DltContext CONTEXT;
  * @param SERVICEID service id of the injection message
  * @param CALLBACK function pointer to callback function
  */
-#define DLT_REGISTER_INJECTION_CALLBACK(CONTEXT, SERVICEID, CALLBACK) \
-       dlt_register_injection_callback(&(CONTEXT),SERVICEID, CALLBACK);
+#define DLT_REGISTER_INJECTION_CALLBACK(CONTEXT, SERVICEID, CALLBACK) do{\
+       dlt_register_injection_callback(&(CONTEXT),SERVICEID, CALLBACK);} while(0)
 
 /**
  * Send log message with variable list of messages (intended for verbose mode)
@@ -167,18 +155,21 @@ extern DltContext CONTEXT;
  * @param ARGS variable list of arguments
  */
 #ifdef _MSC_VER
-  /* DLT_LOG is not supported by MS Visual C++ */
-  /* use function interface instead            */
+/* DLT_LOG is not supported by MS Visual C++ */
+/* use function interface instead            */
 #else
 #define DLT_LOG(CONTEXT,LOGLEVEL,ARGS...) \
-       { \
-               DltContextData log; \
-               if (dlt_user_log_write_start(&CONTEXT,&log,LOGLEVEL)) \
+       do { \
+               if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
                { \
-            ARGS; \
-            dlt_user_log_write_finish(&log); \
+                       DltContextData log; \
+                       if (dlt_user_log_write_start(&CONTEXT,&log,LOGLEVEL)>0) \
+                       { \
+                               ARGS; \
+                               dlt_user_log_write_finish(&log); \
+                       } \
                } \
-       }
+       } while(0)
 #endif
 
 /**
@@ -187,104 +178,114 @@ extern DltContext CONTEXT;
  * @param LOGLEVEL the log level of the log message
  * @param MSGID the message id of log message
  * @param ARGS variable list of arguments: 
         calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
         DLT_INT(), DLT_UINT(), DLT_RAW()
+ calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
+ DLT_INT(), DLT_UINT(), DLT_RAW()
  */
 #ifdef _MSC_VER
-  /* DLT_LOG_ID is not supported by MS Visual C++ */
-  /* use function interface instead               */
+/* DLT_LOG_ID is not supported by MS Visual C++ */
+/* use function interface instead               */
 #else
 #define DLT_LOG_ID(CONTEXT,LOGLEVEL,MSGID,ARGS...) \
-       { \
-               DltContextData log; \
-               if (dlt_user_log_write_start_id(&CONTEXT,&log,LOGLEVEL,MSGID)) \
+       do { \
+               if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
                { \
-            ARGS; \
-            dlt_user_log_write_finish(&log); \
+                       DltContextData log; \
+                       if (dlt_user_log_write_start_id(&CONTEXT,&log,LOGLEVEL,MSGID)>0) \
+                       { \
+                               ARGS; \
+                               dlt_user_log_write_finish(&log); \
+                       } \
                } \
-       }
+       } while(0)
 #endif
 
 /**
  * Add string parameter to the log messsage.
  * @param TEXT ASCII string
  */
-#define DLT_STRING(TEXT) ({ \
-        dlt_user_log_write_string(&log,TEXT); \
-       })
+#define DLT_STRING(TEXT) \
+        dlt_user_log_write_string(&log,TEXT)
+
+/**
+ * Add constant string parameter to the log messsage.
+ * @param TEXT Constant ASCII string
+ */
+#define DLT_CSTRING(TEXT) \
+        dlt_user_log_write_constant_string(&log,TEXT)
+
+/**
+ * Add utf8-encoded string parameter to the log messsage.
+ * @param TEXT UTF8-encoded string
+ */
+#define DLT_UTF8(TEXT) \
+        dlt_user_log_write_utf8_string(&log,TEXT)
 
 /**
  * Add boolean parameter to the log messsage.
  * @param BOOL_VAR Boolean value (mapped to uint8)
  */
-#define DLT_BOOL(BOOL_VAR) ({ \
-        dlt_user_log_write_bool(&log,BOOL_VAR); \
-       })
+#define DLT_BOOL(BOOL_VAR) \
+        dlt_user_log_write_bool(&log,BOOL_VAR)
 
 /**
  * Add float32 parameter to the log messsage.
  * @param FLOAT32_VAR Float32 value (mapped to float)
  */
-#define DLT_FLOAT32(FLOAT32_VAR) ({ \
-        dlt_user_log_write_float32(&log,FLOAT32_VAR); \
-       })
+#define DLT_FLOAT32(FLOAT32_VAR) \
+        dlt_user_log_write_float32(&log,FLOAT32_VAR)
 
 /**
  * Add float64 parameter to the log messsage.
  * @param FLOAT64_VAR Float64 value (mapped to double)
  */
-#define DLT_FLOAT64(FLOAT64_VAR) ({ \
-        dlt_user_log_write_float64(&log,FLOAT64_VAR); \
-       })
+#define DLT_FLOAT64(FLOAT64_VAR) \
+        dlt_user_log_write_float64(&log,FLOAT64_VAR)
 
 /**
  * Add integer parameter to the log messsage.
  * @param INT_VAR integer value
  */
-#define DLT_INT(INT_VAR) ({ \
-        dlt_user_log_write_int(&log,INT_VAR); \
-       })
-#define DLT_INT8(INT_VAR) ({ \
-        dlt_user_log_write_int8(&log,INT_VAR); \
-       })
-#define DLT_INT16(INT_VAR) ({ \
-        dlt_user_log_write_int16(&log,INT_VAR); \
-       })
-#define DLT_INT32(INT_VAR) ({ \
-        dlt_user_log_write_int32(&log,INT_VAR); \
-       })
-#define DLT_INT64(INT_VAR) ({ \
-        dlt_user_log_write_int64(&log,INT_VAR); \
-       })
+#define DLT_INT(INT_VAR) \
+        dlt_user_log_write_int(&log,INT_VAR)
+
+#define DLT_INT8(INT_VAR) \
+        dlt_user_log_write_int8(&log,INT_VAR)
+
+#define DLT_INT16(INT_VAR) \
+        dlt_user_log_write_int16(&log,INT_VAR)
+
+#define DLT_INT32(INT_VAR) \
+        dlt_user_log_write_int32(&log,INT_VAR)
+
+#define DLT_INT64(INT_VAR) \
+        dlt_user_log_write_int64(&log,INT_VAR)
 
 /**
  * Add unsigned integer parameter to the log messsage.
  * @param UINT_VAR unsigned integer value
  */
-#define DLT_UINT(UINT_VAR) ({ \
-        dlt_user_log_write_uint(&log,UINT_VAR); \
-       })
-#define DLT_UINT8(UINT_VAR) ({ \
-        dlt_user_log_write_uint8(&log,UINT_VAR); \
-       })
-#define DLT_UINT16(UINT_VAR) ({ \
-        dlt_user_log_write_uint16(&log,UINT_VAR); \
-       })
-#define DLT_UINT32(UINT_VAR) ({ \
-        dlt_user_log_write_uint32(&log,UINT_VAR); \
-       })
-#define DLT_UINT64(UINT_VAR) ({ \
-        dlt_user_log_write_uint64(&log,UINT_VAR); \
-       })
+#define DLT_UINT(UINT_VAR) \
+        dlt_user_log_write_uint(&log,UINT_VAR)
+
+#define DLT_UINT8(UINT_VAR) \
+        dlt_user_log_write_uint8(&log,UINT_VAR)
+
+#define DLT_UINT16(UINT_VAR) \
+        dlt_user_log_write_uint16(&log,UINT_VAR)
+
+#define DLT_UINT32(UINT_VAR) \
+        dlt_user_log_write_uint32(&log,UINT_VAR)
+
+#define DLT_UINT64(UINT_VAR) \
+        dlt_user_log_write_uint64(&log,UINT_VAR)
 
 /**
  * Add binary memory block to the log messages.
  * @param BUF pointer to memory block
  * @param LEN length of memory block
  */
-#define DLT_RAW(BUF,LEN) ({ \
-        dlt_user_log_write_raw(&log,BUF,LEN); \
-       })
+#define DLT_RAW(BUF,LEN) \
+        dlt_user_log_write_raw(&log,BUF,LEN)
 
 /**
  * Trace network message
@@ -296,9 +297,46 @@ extern DltContext CONTEXT;
  * @param PAYLOAD pointer to network message payload
  */
 #define DLT_TRACE_NETWORK(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \
-    { \
-        dlt_user_trace_network(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
-    }
+    do { \
+       if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \
+       { \
+               dlt_user_trace_network(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
+               } \
+    }while(0)
+
+/**
+ * Trace network message, allow truncation
+ * @param CONTEXT object containing information about one special logging context
+ * @param TYPE type of network trace message
+ * @param HEADERLEN length of network message header
+ * @param HEADER pointer to network message header
+ * @param PAYLOADLEN length of network message payload
+ * @param PAYLOAD pointer to network message payload
+ */
+#define DLT_TRACE_NETWORK_TRUNCATED(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \
+    do { \
+       if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \
+       { \
+               dlt_user_trace_network_truncated(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD, 1); \
+               } \
+    }while(0)
+
+/**
+ * Trace network message, segment large messages
+ * @param CONTEXT object containing information about one special logging context
+ * @param TYPE type of network trace message
+ * @param HEADERLEN length of network message header
+ * @param HEADER pointer to network message header
+ * @param PAYLOADLEN length of network message payload
+ * @param PAYLOAD pointer to network message payload
+ */
+#define DLT_TRACE_NETWORK_SEGMENTED(CONTEXT,TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD) \
+    do { \
+       if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \
+       { \
+               dlt_user_trace_network_segmented(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
+       } \
+    }while(0)
 
 /**
  * Send log message with string parameter.
@@ -307,10 +345,12 @@ extern DltContext CONTEXT;
  * @param TEXT ASCII string
  */
 #define DLT_LOG_STRING(CONTEXT,LOGLEVEL,TEXT) \
-    { \
-        dlt_log_string(&(CONTEXT), LOGLEVEL, TEXT); \
-    }
-
+    do { \
+               if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
+               { \
+                       dlt_log_string(&(CONTEXT), LOGLEVEL, TEXT); \
+               } \
+    } while(0)
 
 /**
  * Send log message with string parameter and integer parameter.
@@ -320,9 +360,12 @@ extern DltContext CONTEXT;
  * @param INT_VAR integer value
  */
 #define DLT_LOG_STRING_INT(CONTEXT,LOGLEVEL,TEXT,INT_VAR) \
-       { \
-        dlt_log_string_int(&(CONTEXT), LOGLEVEL, TEXT, INT_VAR); \
-       }
+       do { \
+               if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
+               { \
+                       dlt_log_string_int(&(CONTEXT), LOGLEVEL, TEXT, INT_VAR); \
+               } \
+       } while(0)
 
 /**
  * Send log message with string parameter and unsigned integer parameter.
@@ -332,9 +375,12 @@ extern DltContext CONTEXT;
  * @param UINT_VAR unsigned integer value
  */
 #define DLT_LOG_STRING_UINT(CONTEXT,LOGLEVEL,TEXT,UINT_VAR) \
-       { \
-               dlt_log_string_uint(&(CONTEXT),LOGLEVEL,TEXT,UINT_VAR); \
-       }
+       do { \
+               if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
+               { \
+                       dlt_log_string_uint(&(CONTEXT),LOGLEVEL,TEXT,UINT_VAR); \
+               } \
+       } while(0)
 
 /**
  * Send log message with unsigned integer parameter.
@@ -343,9 +389,12 @@ extern DltContext CONTEXT;
  * @param UINT_VAR unsigned integer value
  */
 #define DLT_LOG_UINT(CONTEXT,LOGLEVEL,UINT_VAR) \
-       { \
-               dlt_log_uint(&(CONTEXT),LOGLEVEL,UINT_VAR); \
-       }
+       do { \
+               if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
+               { \
+                       dlt_log_uint(&(CONTEXT),LOGLEVEL,UINT_VAR); \
+               } \
+       } while(0)
 
 /**
  * Send log message with integer parameter.
@@ -354,9 +403,12 @@ extern DltContext CONTEXT;
  * @param INT_VAR integer value
  */
 #define DLT_LOG_INT(CONTEXT,LOGLEVEL,INT_VAR) \
-       { \
-               dlt_log_int(&(CONTEXT),LOGLEVEL,INT_VAR); \
-       }
+       do { \
+               if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
+               { \
+                       dlt_log_int(&(CONTEXT),LOGLEVEL,INT_VAR); \
+               } \
+       } while(0)
 
 /**
  * Send log message with binary memory block.
@@ -366,23 +418,26 @@ extern DltContext CONTEXT;
  * @param LEN length of memory block
  */
 #define DLT_LOG_RAW(CONTEXT,LOGLEVEL,BUF,LEN) \
-       { \
-               dlt_log_raw(&(CONTEXT),LOGLEVEL,BUF,LEN); \
-       }
+       do { \
+               if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
+               { \
+                       dlt_log_raw(&(CONTEXT),LOGLEVEL,BUF,LEN); \
+               } \
+       } while(0)
 
 /**
  * Switch to verbose mode
  *
  */
-#define DLT_VERBOSE_MODE() \
-       dlt_verbose_mode();
+#define DLT_VERBOSE_MODE() do { \
+       dlt_verbose_mode();} while(0)
 
 /**
  * Switch to non-verbose mode
  *
  */
-#define DLT_NONVERBOSE_MODE() \
-       dlt_nonverbose_mode();
+#define DLT_NONVERBOSE_MODE() do {\
+       dlt_nonverbose_mode();} while(0)
 
 /**
  * Set maximum logged log level and trace status of application
@@ -390,25 +445,25 @@ extern DltContext CONTEXT;
  * @param LOGLEVEL This is the log level to be set for the whole application
  * @param TRACESTATUS This is the trace status to be set for the whole application
  */
-#define DLT_SET_APPLICATION_LL_TS_LIMIT(LOGLEVEL, TRACESTATUS) \
-    dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS);
+#define DLT_SET_APPLICATION_LL_TS_LIMIT(LOGLEVEL, TRACESTATUS) do {\
+    dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS);} while(0)
 
 /**
  * Enable local printing of messages
  *
  */
-#define DLT_ENABLE_LOCAL_PRINT() \
-       dlt_enable_local_print();
+#define DLT_ENABLE_LOCAL_PRINT() do {\
+       dlt_enable_local_print();} while(0)
 
 /**
  * Disable local printing of messages
  *
  */
-#define DLT_DISABLE_LOCAL_PRINT() \
-       dlt_disable_local_print();
+#define DLT_DISABLE_LOCAL_PRINT() do {\
+       dlt_disable_local_print();} while(0)
 
 /**
 \}
-*/
+ \}
+ */
 
 #endif /* DLT_USER_MACROS_H */