On Mon, Jul 20, 2009 at 1:20 AM, Bernhard 'Gustl' Bauer <[email protected]>wrote:

> Hi,
>
> I just had a look at the define of LWIP_DEBUGF. I wonder whats the use of
> the do {} while(0) statement. Its contens is executed one time, so the loop
> can be omitted, isn't it?
>
> Gustl
>
> #define LWIP_DEBUGF(debug,x) do { \
>  if ( \
>    ((debug) & LWIP_DBG_ON) && \
>    ((debug) & LWIP_DBG_TYPES_ON) && \
>    ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
>    LWIP_PLATFORM_DIAG(x); \
>    if ((debug) & LWIP_DBG_HALT) { \
>      while(1); \
>    } \
>  } \
> } while(0)
>

In order to insert all those lines in a #define you have to start it with
something "do{" uses the least chars, and the compiler probably edits it
out.
In a non-debug scenario the line would just be:
#define LWIP_DEBUGF(debug,x)

Enjoy,

*E
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to