char vs. int in arg decls

Rick Genter rgenter at labs-b.bbn.com
Wed Sep 17 00:35:05 AEST 1986


     Yes, it will work to interchange (int) and (char) as the types of 
function arguments, as long as you *never* use &, or *only* work on VAXen
(and similar-endian machines).  At my previous employer we had a late-night
hacker who had written a really nice screen editor.  One day I tried to port
it to the Sun.  Nothing worked (core dumped before clearing the screen).  I
started to track it down, then noticed things like:

		<...>
	add_char_to_line (':');		/* draw border */
		<...>

	add_char_to_line (c)
	{				/* no decl for c, so default to int */
		<...>
		ins_char_in_buffer (& c, & buf);
	}

	ins_char_in_buffer (cp, bufp)
	char *cp;
	BUF *bufp;
	{
		<...>
	}

Needless to say, this kind of coding was sprinkled throughout the source.
Dennis would have liked this guy; I said "lint" to him and he replied "?" :-).

     The moral of the story: say what you mean, even if it *usually* doesn't
matter.
--------
Rick Genter 				BBN Laboratories Inc.
(617) 497-3848				10 Moulton St.  6/512
rgenter at labs-b.bbn.COM  (Internet new)	Cambridge, MA   02238
rgenter at bbn-labs-b.ARPA (Internet old)	linus!rgenter%BBN-LABS-B.ARPA (UUCP)



More information about the Comp.lang.c mailing list