[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GCC complaints about missing braces around initializer
From: |
Pavel Janík |
Subject: |
Re: GCC complaints about missing braces around initializer |
Date: |
Wed, 05 Dec 2001 07:09:49 +0100 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1.50 (i386-suse-linux-gnu) |
From: "Stefan Monnier" <monnier+gnu/address@hidden>
Date: Tue, 04 Dec 2001 21:55:31 -0500
Hi Stefan,
> When compiling with -Wall GCC complaints about missing braces around
> initializers because the code does
>
> struct foo var[] = { a11, a12, a13, a21, a22, a23 };
>
> instead of
>
> struct foo var[] = { {a11, a12, a13}, {a21, a22, a23} };
>
> is there a reason why the code is written this way or can I safely
> change it to something that GCC likes better ?
when we decide to use the second one, please do not spend your time on
it. I have already did that and use it for about four months now (with many
similar changes - if you use -Wall, you know what I'm talking about ;-). So
I can do it and you can concentrate on things which need more Emacs
know-how (that you have and I am still missing sometimes :-).
> It seems like it should be fair since the syntax preferred by GCC
> is already used in various places, but I'd rather make sure,
> because my memory of C's history is too fuzzy.
The similar applies to:
if (c1 > 0 && c1 < 32 || c2 > 0 && c2 < 32)
return -1;
gcc here warns:
charset.c:236: warning: suggest parentheses around && within ||
This is however perfectly legal C. Although I (and gcc too ;-) prefer to
use
if ((c1 > 0 && c1 < 32) || (c2 > 0 && c2 < 32))
return -1;
which is more readable and clear for humans.
gcc issues some warning also here:
while (str = fgets (string, BUFSIZ, in))
printf ("%s", str);
warning: suggest parentheses around assignment used as truth value
So to prevent it, one should wrote:
while ((str = fgets (string, BUFSIZ, in)))
printf ("%s", str);
I have already patches for similar things in my tree.
--
Pavel Janík
/* Thanks to Rob `CmdrTaco' Malda for not influencing this code in any
* way.
*/
-- 2.4.3 net/core/netfilter.c
- Re: New mh-e toolbar icons, (continued)
- Re: New mh-e toolbar icons, Richard Stallman, 2001/12/04
- Re: New mh-e toolbar icons, Peter S Galbraith, 2001/12/04
- Too new DOC file or .elc file, Stefan Monnier, 2001/12/04
- Re: Too new DOC file or .elc file, Richard Stallman, 2001/12/05
- Re: Too new DOC file or .elc file, Stefan Monnier, 2001/12/06
- GCC complaints about missing braces around initializer, Stefan Monnier, 2001/12/04
- Re: GCC complaints about missing braces around initializer,
Pavel Janík <=
- Re: GCC complaints about missing braces around initializer, Richard Stallman, 2001/12/05
- Re: GCC complaints about missing braces around initializer, Pavel Janík, 2001/12/08
- Re: GCC complaints about missing braces around initializer, Richard Stallman, 2001/12/05
- Re: GCC complaints about missing braces around initializer, Paul Eggert, 2001/12/07
- Re: GCC complaints about missing braces around initializer, Pavel Janík, 2001/12/08
- Re: New mh-e toolbar icons, Eli Zaretskii, 2001/12/05
- Re: New mh-e toolbar icons, Bill Wohler, 2001/12/05
- Re: New mh-e toolbar icons, Richard Stallman, 2001/12/03
Re: New mh-e toolbar icons, Jason Rumney, 2001/12/04