Article View: net.lang.c
Article #9332char vs. int in arg decls
From: Rick Genter
Date: Tue, 16 Sep 1986 14:35
Date: Tue, 16 Sep 1986 14:35
35 lines
1623 bytes
1623 bytes
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@labs-b.bbn.COM (Internet new) Cambridge, MA 02238
rgenter@bbn-labs-b.ARPA (Internet old) linus!rgenter%BBN-LABS-B.ARPA (UUCP)
Technical Details
Message-ID:
<3868@brl-smoke.ARPA>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!brl-adm!brl-smoke!smoke!rgenter@labs-b.bbn.comShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!brl-adm!brl-smoke!smoke!rgenter@labs-b.bbn.com From: rgenter@labs-b.bbn.com (Rick Genter) Newsgroups: net.lang.c Subject: char vs. int in arg decls Message-ID: <3868@brl-smoke.ARPA> Date: Tue, 16-Sep-86 10:35:05 EDT Article-I.D.: brl-smok.3868 Posted: Tue Sep 16 10:35:05 1986 Date-Received: Sat, 20-Sep-86 00:30:43 EDT Sender: news@brl-smoke.ARPA Lines: 35