On 9 Sep, 20:49, Harald van D©¦k <true...@gmail.comwrote:
Quote:
On Tue, 09 Sep 2008 15:20:10 -0400, Bill Cunningham wrote:
Quote:
Quote:
Is extern used to externalize functions as well as variables?
>
No.
? I'd have said "yes"
Quote:
Quote:
If I have this function,
>
>
Quote:
Should it be declared as above in the file in which main is called and
compiled with the file that contains num's body? Or should it be
declared as this,
>
Quote:
extern num (int n);
>
No. Why did you decide to remove "int"?
>
You can declare it as either "int num(int n);" or
"extern int num(int n);", either in a header file or directly in the file
where you want to call num. "extern" doesn't mean anything extra here.
I don't actually use extern on functions as by default they are
extern.
If you want to confine them to a single file use static.
Bill, try reading section 4.3 of K&R 2e. Though for once I found K&R
a bit heavy going in this area.
Unfortunatly ANSI had a bit of a job here. They try to explain
both what you should do (best practice) and what you can do
(so as not to break existing code)
--
Nick Keighley
quark: The sound made by a well bred duck.