lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Print Macros


From: Robert
Subject: Re: [lwip-users] Print Macros
Date: Thu, 14 Apr 2011 08:23:04 -0400

On Wed, 2011-04-13 at 16:17 -0700, Roger Cover wrote:
Greetings List,
 
My compiler does not substitute macros inside quotes. The proposed change would not work for me at all, since the example in the original message would result in a final string of "tcp_bind: bind to port %U16_F\n".
Regards,
Roger


My compiler tries to process the format string at compile time, so that the application will run faster during execution.  That is the reason it fails with the macros as coded now. It apparently does that scan before concatenating the string.  So how about this:

Code the macros like this:


#define U16_F  "%u"

Then the invocation would look like this:


LWIP_DEBUG(TCP_DEBUG,("tcb_bind: bind to part "U16_F"\n, port));

The change here is that the % sign is part of the substitution rather than before.  The only disadvantage I think is that there are a few cases in the code where a "length" of the field is specified, and those would need their own macros.

Robert Laughlin
reply via email to

[Prev in Thread] Current Thread [Next in Thread]