lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Print Macros


From: Bill Auerbach
Subject: Re: [lwip-users] Print Macros
Date: Thu, 14 Apr 2011 09:17:04 -0400

A format specifier is syntactically a % followed by optional width & precision and the final format type.  IMO the macro should include % to keep it together.  But I know it will involve many many changes through practically every file in the lwIP code base.

 

Bill

 

From: address@hidden [mailto:address@hidden On Behalf Of Robert
Sent: Thursday, April 14, 2011 8:23 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Print Macros

 

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]