Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > hassle with macro

Reply
Thread Tools

hassle with macro

 
 
Mark
Guest
Posts: n/a
 
      04-26-2010
I have a piece of code having these lines:

#define ET_ERROR(args) fprintf(args)
....
ET_ERROR(("bus %d slot %d", bus, slot)); /* XX */

This causes compilation warnings:

warning: left-hand operand of comma expression has no effect
warning: passing argument 1 of 'printf' makes pointer from integer without a
cast

Obviously the second is the consequence of the first. As Im understand the
compiler treats expression found in parentheses of printf as a comma
operator. Is there any way to make it work, except changing a number of
arguments to macro, as there are lots of such macros scattered around the
code?

--
Mark

 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      04-26-2010
"Mark" <(E-Mail Removed)> writes:

> I have a piece of code having these lines:
>
> #define ET_ERROR(args) fprintf(args)
> ...
> ET_ERROR(("bus %d slot %d", bus, slot)); /* XX */


If ET_ERROR is intended to be invoked that way, then it should be
defined this way:
#define ET_ERROR(args) fprintf args
--
Ben Pfaff
http://benpfaff.org
 
Reply With Quote
 
 
 
 
Mark
Guest
Posts: n/a
 
      04-26-2010
Ben Pfaff wrote:
>> I have a piece of code having these lines:
>>
>> #define ET_ERROR(args) fprintf(args)
>> ...
>> ET_ERROR(("bus %d slot %d", bus, slot)); /* XX */

>
> If ET_ERROR is intended to be invoked that way, then it should be
> defined this way:
> #define ET_ERROR(args) fprintf args

Thank you very much indeed!

--
Mark
 
Reply With Quote
 
Ralf Damaschke
Guest
Posts: n/a
 
      04-26-2010
Ben Pfaff wrote:

> "Mark" <(E-Mail Removed)> writes:
>
>> I have a piece of code having these lines:
>>
>> #define ET_ERROR(args) fprintf(args)
>> ...
>> ET_ERROR(("bus %d slot %d", bus, slot)); /* XX */

>
> If ET_ERROR is intended to be invoked that way, then it should be
> defined this way:
> #define ET_ERROR(args) fprintf args


Hmm, if ET_ERROR is intended to be invoked that way, then it should
better be defined this way:

#define ET_ERROR(args) printf args

-- Ralf
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hassle with layout Paul Watt HTML 3 04-04-2006 02:23 PM
Only ONE real Firefox hassle: newsgroup & IRC tabs HellPope Huey Firefox 3 07-27-2005 02:34 AM
Postback, a hassle!? SparvHok ASP .Net 2 12-07-2004 07:19 PM
Looking For Bare Bones Computer Not a Hassle Keith Computer Support 4 06-02-2004 07:04 PM
Googles DROP DOWN MENU IS A HASSLE Greg1951 Computer Support 1 12-25-2003 04:41 PM



Advertisments