Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > When did K&R function declarations become obsolete?

Reply
Thread Tools

When did K&R function declarations become obsolete?

 
 
Alan Mackenzie
Guest
Posts: n/a
 
      12-10-2011
I think we can say that K&R function declarations are truly obsolete. In
~20 years of hacking C, I've only seen very old code which uses them.

Presumably these declarations are still widely used in compiler validation
suites but nowhere else.

Approximately when did they become obsolete, i.e. not used at all for new
code?

[Context: I'm writing documentation for Emacs's C Mode.]

--
Alan Mackenzie (Nuremberg, Germany).

 
Reply With Quote
 
 
 
 
88888 Dihedral
Guest
Posts: n/a
 
      12-10-2011
The _fastcall, _cdecl, _pascall were used everywhere.

Do you really know how c functions are called in the run time ?

 
Reply With Quote
 
 
 
 
Kaz Kylheku
Guest
Posts: n/a
 
      12-10-2011
On 2011-12-10, Alan Mackenzie <(E-Mail Removed)> wrote:
> I think we can say that K&R function declarations are truly obsolete. In
> ~20 years of hacking C, I've only seen very old code which uses them.


These declarations are still a feature of the 1999 C language, but marked as
obsolescent ISO 9899:1999:

6.11.7 Function definitions

1 The use of function definitions with separate parameter identifier and
declaration lists (not prototype-format parameter type and identifier
declarators) is an obsolescent feature.

(If you want to know about the current draft status of this, Google it up;
I dont' know.)

> Presumably these declarations are still widely used in compiler validation
> suites but nowhere else.


They likely appear in some nonzero but impossible to quantify amount of legacy
code.

Some open source programs still use old style definitions, coupled with
prototype declarations.

E.g.:

int func PROTO(( char *, int ));

/* ... */

int func(a, b)
char *a;
int b;
{
/*...*/
}

Are these programs rare? In some sense, yes, but in fact we do not have to go
far to find an example.

For instance, oh, the GNU C Library (glibc):

http://sourceware.org/git/?p=glibc.g...ob;f=io/open.c

Snippet retrieved Sat Dec 10 10:40:55 PST 2011:

/* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
a third argument is the file protection. */
int
__open (file, oflag)
const char *file;
int oflag;
{
int mode;

if (file == NULL)
{
__set_errno (EINVAL);
return -1;
}

> Approximately when did they become obsolete, i.e. not used at all for new
> code?


This is impossible to know, without a crystal ball that peers into
what everyone on the planet is coding.
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      12-10-2011
On 12/11/11 07:40 AM, 88888 Dihedral wrote:
> The _fastcall, _cdecl, _pascall were used everywhere.


The what?

> Do you really know how c functions are called in the run time ?


What on Earth is this nonsense in reply to?

--
Ian Collins
 
Reply With Quote
 
Ben Pfaff
Guest
Posts: n/a
 
      12-10-2011
88888 Dihedral <(E-Mail Removed)> writes:

> The _fastcall, _cdecl, _pascall were used everywhere.


....in Windows and perhaps MS-DOS code and nowhere else, and are
completely orthogonal to the transition from K&R to
prototype-style function declarations.
--
Ben Pfaff
http://benpfaff.org
 
Reply With Quote
 
Jens Thoms Toerring
Guest
Posts: n/a
 
      12-10-2011
Alan Mackenzie <(E-Mail Removed)> wrote:
> I think we can say that K&R function declarations are truly obsolete. In
> ~20 years of hacking C, I've only seen very old code which uses them.


> Presumably these declarations are still widely used in compiler validation
> suites but nowhere else.


> Approximately when did they become obsolete, i.e. not used at all for new
> code?


When I started using C in 1989 they were still quite common to be
seen in code I was looking at but that dropped significantly during
the following decade and I hardly ever have seen code using them
written in this millenium. So my very personal guess is that most
people use the "new" form since at least about 1995. But then I did
programming nearly exclussively under UNIX, things might be diffe-
rent for platforms were "modern" compilers weren't available that
easily. And, of course, people having to cater for the very smal-
lest common denominator (i.e. systems were no C89 compliant com-
piler exists) still have to use them in one form or another (as
the example Kaz came up with might be an example for).

If this is for the emacs C mode then, since the standard still
requires support for the "old way" (even though it might be de-
clared as obsolete) I would think it prudent not to throw it
out completely.
Regards, Jens
--
\ Jens Thoms Toerring ___ http://www.velocityreviews.com/forums/(E-Mail Removed)
\__________________________ http://toerring.de
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      12-10-2011
Alan Mackenzie <(E-Mail Removed)> writes:
> I think we can say that K&R function declarations are truly obsolete. In
> ~20 years of hacking C, I've only seen very old code which uses them.
>
> Presumably these declarations are still widely used in compiler validation
> suites but nowhere else.
>
> Approximately when did they become obsolete, i.e. not used at all for new
> code?
>
> [Context: I'm writing documentation for Emacs's C Mode.]


I'm not aware that they've ever become completely obsolete in that
sense. One poster in comp.std.c, Jun Woong, is apparently still using
them (unnecessarily IMHO, but I can see his point); see Message-ID
<(E-Mail Removed)>,
<http://groups.google.com/group/comp.std.c/msg/819a7f3553366ef8>.

They've been *obsolescent* since C89 (see 6.9.4 and 6.9.5 in the
C90 standard, presumably 3.9.4 and 3.9.5 in the C99 standard),
and remain so in the latest C201X draft.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Ralph Spitzner
Guest
Posts: n/a
 
      12-11-2011
Alan Mackenzie wrote:
> I think we can say that K&R function declarations are truly obsolete. In
> ~20 years of hacking C, I've only seen very old code which uses them.


Sorry, but having read the thread so far I still don't get it.
Are you guys talking about declarations, or implementations ?

After all to avoid an implicit declaration as 'int (void)'
(or (int), for that matter) one would have to declare in some.h like:

char *myfunc(char *);

then implement it as either

char *
myfunc(char *thestring)
{
....
}

or old

char *myfunc(thestring)
char *thestring;
{
....
}

What am I missing here, a proper C course ?

-rasp
 
Reply With Quote
 
ralph
Guest
Posts: n/a
 
      12-11-2011
On Sat, 10 Dec 2011 18:23:19 +0000 (UTC), Alan Mackenzie <(E-Mail Removed)>
wrote:

>I think we can say that K&R function declarations are truly obsolete. In
>~20 years of hacking C, I've only seen very old code which uses them.
>
>Presumably these declarations are still widely used in compiler validation
>suites but nowhere else.
>
>Approximately when did they become obsolete, i.e. not used at all for new
>code?
>
>[Context: I'm writing documentation for Emacs's C Mode.]


As Mr. Thompson pointed out the closest to an "official" date would be
C89, however K&R fell out of common use long before that. Most C
compilers I used by the early 80s offered vendor specific
implementations that supported the "ANSI style", though there wasn't
any official 'ANSI' yet.

The only C compiler I remember by name and version is Microsoft C 3.0
(XENIX) and it was what we would call fully "ANSI compatible" in 1985.
Other platform compilers I used earlier all had the ANSI-style option
available before then. And we all quickly jumped at using it whenever
it was available.

[The reason I'm so vague is because back then just about every box
came with its own "C compiler" or managment sprang for some 3rd-party
"development package" - the fine-print contained a copyright of some
sort but you seldom paid much attention to it, unless there was a
difference in some obscure library. And then you were likely to code a
conditional compile for the "VAX-C", or for accounting's "XENIX-BOX",
etc.]

I've been trying to remember when I last was forced to use pure K&R
and I think it was a DEC VAX/VMS project in 1983???

-ralph
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      12-11-2011
Keith Thompson <(E-Mail Removed)> writes:
[...]
> They've been *obsolescent* since C89 (see 6.9.4 and 6.9.5 in the
> C90 standard, presumably 3.9.4 and 3.9.5 in the C99 standard),
> and remain so in the latest C201X draft.


Sorry, I meant 3.9.4 and 3.9.5 in the ANSI C89 standard. (ISO C90
described the same language, but renumbered the sections.)

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Become The master in computer hardware to become successfull shilla Computer Security 1 01-22-2011 06:19 PM
When did the photographer become .... Pat Digital Photography 20 10-22-2007 04:11 PM
Since when did $29.99 become standard msrp? Goro DVD Video 5 10-22-2005 06:44 AM
Doris Day: When did she become a virgin? Scot Gardner DVD Video 18 10-19-2003 10:15 AM



Advertisments