🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2137

"extern" and function declarations

#2137
From: Lawrence Kirby
Date: Fri, 01 Mar 1996 15:37
38 lines
1681 bytes
In article <4h2s5p$ok@solutions.solon.com>
           clgonsal@undergrad.math.uwaterloo.ca
           "Carl Laurence Gonsalves" writes:

 > Is there any difference in the meaning between the following two
 > declarations?
 > 
 > extern int foo( void );
 > int foo( void );

No, they are entirely equivalent.

 > In other words, is "extern" ever necessary before a function prototype?

I assume you mean declaration - a prototype is something like:

   int foo( void );

as opposed to something like:

   int foo();

No, extern is never necessary for function declarations.

 > I've never used "extern" for function declarations before, and recently
 > I've seen some code which uses extern in front of the prototypes in the
 > headers. I'm wondering, is it okay to leave out extern, or is there a
 > possibility that some compiler/linker will have problems if I leave it
 > out?

It isn't a problem with ANSI compilers and I have never come across a
pre-ANSI compiler where it was a problem. It is just a stylistic issue.

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID: <4h75it$4t3@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: fred@genesis.demon.co.uk (Lawrence Kirby)
Newsgroups: comp.lang.c.moderated
Subject: "extern" and function declarations
Date: 1 Mar 1996 09:37:01 -0600
Organization: none
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4h75it$4t3@solutions.solon.com>
Reply-To: fred@genesis.demon.co.uk
NNTP-Posting-Host: solutions.solon.com
X-Mailer: Demon Internet Simple News v1.27