[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: obstack_printf
From: |
Eric Blake |
Subject: |
Re: obstack_printf |
Date: |
Sat, 14 Jun 2008 06:54:51 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Jim Meyering on 6/14/2008 2:04 AM:
| Bruno Haible <address@hidden> wrote:
| ...
|> 1) This C code
|>
|> const size_t cutoff = 1024;
|> char buf[cutoff];
|>
|> is understood only by gcc, Tru64 cc, IRIX cc. It fails to compile on
other C
|> compilers:
Bruno, thanks for the cleanup.
|> ! const size_t cutoff = 1024;
|> ! char buf[cutoff];
| ...
|> --- 58,73 ----
|> ! #define CUTOFF 1024
|> ! char buf[CUTOFF];
|
| Why not use an enum, as you suggested above?
|
| enum { CUTOFF = 1024 };
| char buf[CUTOFF];
|
| Then you can copy/paste expressions involving "CUTOFF" into
| debuggers that don't know about CPP-defined symbols.
|
| Besides, code without cpp directives just looks better ;-)
|
I likewise much prefer the enum-style of code over macros, having used it
myself elsewhere. I'm not sure what qualifies as mainstream, but using
enum for int constants is certainly not a foreign coding concept.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkhTv5sACgkQ84KuGfSFAYAr+gCeNUrLW1Sg/D+a2oeIYP9YiMya
e/YAnAqKgo+jHrH1gY8My1jBA1tOUkX8
=Bhem
-----END PGP SIGNATURE-----