This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Fwd: Re: Problem compiling fdutils 5.4
- To: Pierre <pierre at epinetworx dot com>
- Subject: Re: Fwd: Re: Problem compiling fdutils 5.4
- From: Zack Weinberg <zack at codesourcery dot com>
- Date: Sun, 30 Sep 2001 16:53:09 -0700
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <20010928201053.C5879@pierre.epinetworx.com> <200109290603.f8T63t423943@hitchhiker.org.lu> <20011001012712.A4722@pierre.epinetworx.com>
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