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