Re: Patch for gnome-common/support/vsnprintf.c (fwd)



-----BEGIN PGP SIGNED MESSAGE-----

On 20 May 1998, Tom Tromey wrote:

> To: martin@home-of-linux.org
> Subject: Re: Patch for gnome-common/support/vsnprintf.c (fwd)
> From: Tom Tromey <tromey@cygnus.com>
> 
> Martin> * vsnprintf.c (vsnprintf): Added prototype for systems
> Martin> defining __STDC__.
> 
> FYI it's almost always incorrect to add a prototype for a library
> function just to avoid a warning on some system.  You should only add
> a prototype if it fixes an actual bug, or if you add it in such a way
> that the prototype will not be seen on systems that have a prototype
> in some system header file.

Oops, yes you're correct - 'added prototype' in the log message was really
wrong; I changed the declaration of the function, not the prototype.

It was declared as

	int
	vsnprintf(str, n, fmt, ap)
	        char *str;
	        size_t n; 
	        char *fmt;
	        char *ap;

which conflicted with the prototype in the system header file on DEC
OSF/1, so I changed it into

	int
	#if __STDC__
	vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
	#else
	vsnprintf(str, n, fmt, ap)
	        char *str;
	        size_t n;
	        char *fmt;
	        char *ap;
	#endif

> The reason is that despite things like POSIX and ISO C, system headers
> still differ.  Any prototype you add is likely to be wrong on one
> system or another.  Yes, this sucks.

That's true. And the suck is that also the actual declaration of the
function may clash with a prototype in some system header file.

> I haven't actually looked at this particular patch.  I'm just stating
> what I think is a general rule (if you have a contrary opinion, with a
> reason, I'd love to hear it).

Well, you're right. I fixed it in the ChangeLog.

Martin

- -----------------------------------------------------------------
   Martin Baulig - Angewandte Mathematik - Universitaet Trier

   baulig@castor.uni-trier.de, http://www.home-of-linux.org/
   Key: 1024-bit key with ID C8178435 created 1997/01/24 
   ID:  67 C1 84 A0 47 F5 11 C5  5F 68 4C 84 99 05 C3 92
   Finger me for public key or fetch finger.txt from the url above
- ------------------------------------------------------------------


-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: noconv

iQCVAwUBNWQ5oYA8K7jIF4Q1AQHMWQP/V+Gmy5Nz9rGHxJ762FA9SGIe2bFDG+9s
AlGKUCEmEAMqkL5fV4twFs3MFS25D/yVYAkS6abvIIDZuGZtY7ArY6rvosJoeOyI
HlMPJdERAN3Ac8Atqw34O5oW0KuH9Tn7XZrvYiRgl6JnxTqftHlfHDr1tXJIOFXn
agrBiDeXqoU=
=a3v0
-----END PGP SIGNATURE-----



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