pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -Wdeclaration-after-statement


From: John Darrington
Subject: Re: -Wdeclaration-after-statement
Date: Thu, 15 Dec 2011 07:46:18 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

I have mixed feelings.

On the one hand, I do like to be able to declare variables after some
dependent varible has been calculated, because otherwise it's sometimes
impossible to give a const qualifier, when one clearly is warranted.

{
 int x, y;

 init_xy (&x, &y);

 const double z = x / (double) y;
 
 /* I don't want z to change after this point */
}

On the otherhand, I'm not quite so convinced that C99 is as widespread
as soem people think.  Only last week I was scratching my head for an hour
or so over an error thrown up by a Keil compiler which turned out to be
exactly this issue.

On Wed, Dec 14, 2011 at 09:00:56PM -0800, Ben Pfaff wrote:
     I've had PSPP enable -Wdeclaration-after-statement for a long
     time now, because declarations following statements are not
     entirely portable.
     
     However, I've noticed that you are fond of writing code this way.
     GNU coreutils contains some code that writes declarations after
     statements, too, which indicates that support must be pretty
     widespread.  So, I'm thinking about dropping the warning and
     stopping worrying about a portability problem here; it probably
     isn't a real problem any longer.
     
     Any comments?
     
     Thanks,
     
     Ben.
     -- 
     Ben Pfaff 
     http://benpfaff.org

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://keys.gnupg.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]