delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/04/19/17:32:21

Date: Sat, 02 Apr 1994 15:04:32 -0500 (EST)
From: "Wonkoo Kim, EE, U. of Pittsburgh" <WKIM AT vms DOT cis DOT pitt DOT edu>
Subject: Re: storage allocation of global var
To: FIXER AT FAXCSL DOT DCRT DOT NIH DOT GOV
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

>Date: Sat, 02 Apr 1994 09:42:06 -0500 (EST)
>From: "Chris Mr. Tangerine Man Tate" <FIXER AT FAXCSL DOT DCRT DOT NIH DOT GOV>
>Subject: RE: storage allocation of global var
>
>Wonkoo Kim wrote:
>
>> One thing that I'm still wondering is, why include\*.h in gcc or bcc do not
>> have 'extern' specifier for function protocols, but C books[K&R] say that
>> 'extern' is required if it is external.  Is there some difference between
>> builtin *.h and user written *.h?  Or, just omitted 'extern' from
>> include\*.h because of implicit extern capability of the compiler/linker
>> when a function is external to a module but included .h has the non-extern
>> function protocol? 

Oops! function prototype!

>Because funtion prototypes are not the same as variable declarations.
>A function prototype of the form "<return_type> f_name(args...);" is
>just like declaring a variable "extern;" it means that the function
>is going to be defined elsewhere, and it's an error if it isn't (a
>link-time error, that is).  Explicitly declaring a function "extern"
>isn't necessary; functions can only be "extern" or "static."
>
>Obviously, you can't actually *define* a function (that is, provide
>the actual body of its code) more than once.  But prototypes don't do
>that; they just tell the compiler how to handle invocations of that
>function (i.e. how to push arguments onto the stack).
>
>Are you reading the original K&R, or the second edition?  The rules
>have changed a bit for the ANSI spec (mostly for the better, IMHO).  I
>can't find a place where K&R2 says anything about "extern" for function
>prototypes.  For that matter, I've never seen a piece of code that ever
>declared a function "extern" explicitly....

I read the original K&R dated 1978, which was my old friend :)

>Obligatory soapbox:  always use new-style function prototypes.  In
>fact, if you're writing in C, use the -ansi switch habitually.  It'll
>get you into some good habits.  :-)

Thanks for your good information.  I feel my knowledge is getting outdated 
and stayed in early 80's!  I should brush up myself with some recent book.
Now everything is clear to me.

Thank you very much to all who replied!
And, thank you for allowing me to ask non-djgpp-specific question in this 
list. [djgpp list is the most reliable list!]

Wonkoo Kim
wkim AT vms DOT cis DOT pitt DOT edu


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019