[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-bugs
Subject:    Re: Fwd: Re: Problem compiling fdutils 5.4
From:       Zack Weinberg <zack () codesourcery ! com>
Date:       2001-09-30 23:53:09
[Download RAW message or body]

On Mon, Oct 01, 2001 at 01:27:12AM +0200, Pierre wrote:
> Hi,
> 
> I think it could be interesting for you to look at this problem we had.

[printf as a macro]

1. Printf is the responsibility of the standard library, not the
   compiler.  Your complaint is best taken up with the maintainers of
   your C library (which I suspect is GNU libc).

2. The C standard explictly *allows* every standard function to be
   defined as a macro, as long as the functional version really does
   exist, and the behaviors are identical except possibly for
   performance.  GNU libc does this a lot; it is my personal opinion
   that it shouldn't, but I am not a glibc maintainer.

3. Macro invocations may be spread over multiple lines with no
   difficulty.  What is not permitted is placing directives in the
   middle of a macro argument list.  The C standard makes this
   undefined behavior, and we have chosen to make it an error.

4. This block of code is buggy on its face - it provides the wrong
   number of arguments to printf if FD_DISK_CHANGED is not defined.
   No one has noticed, which suggests that FD_DISK_CHANGED is always
   defined.  I would suggest that you simply eliminate the ifdefs,

> 		printf("%s %s %s %s %s\n", 
> 		       drivstat.flags & FD_VERIFY ? "verify" : "",
> 		       drivstat.flags & FD_DISK_NEWCHANGE ? "newchange" : "",
> 		       drivstat.flags & FD_NEED_TWADDLE ? "need_twaddle" : "",
> 		       drivstat.flags & FD_DISK_CHANGED ? "disk_changed" : "",
> 		       drivstat.flags & FD_DISK_WRITABLE ?"disk_writable" : "");

If you are concerned about it, place

#ifndef FD_DISK_CHANGED
#define FD_DISK_CHANGED 0
#endif

at the top of the file.

zw

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic