🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c++
Article #123

Does 'inline' imply 'static'?

#123
From: Rich Wales
Date: Fri, 28 Mar 1986 19:32
34 lines
2204 bytes
If a function is declared "inline" in C++, does/should this mean that
the function is implicitly "static" (i.e., known only within the source
file in which it appears)?

Although section 8.1 of the C++ Reference Manual (in the Stroustrup
book, p. 266) says that "inline" is "only a hint to the compiler, does
not affect the meaning of a program, and may be ignored", consider that
an "inline" function is going to have to be available at compile time
if the compiler is to be able to do an inline expansion.

One would therefore infer that the definition of an "inline" function
must appear in each source file that invokes it (possibly via a header
file; indeed, p. 107 of the book says that inline function definitions
are indeed reasonable things to put in header files).

If "inline" functions were not implicitly "static", though, defining
one in multiple source files (via a header file, for instance) would
lead to multiple external definitions of the function, with resulting
linker errors.

So, it seems that "inline" functions must be treated as being "static"
-- though I am unable to find anything in the book that states this in
so many words.

I have not yet started to play with the C++ translator, by the way
(though we do have it here at UCLA); I have so far been going only on
the basis of the language description in the book.

Also, my apologies if this topic has already been discussed; I started
reading this newsgroup only a short while ago.
-- 
Rich Wales // UCLA Computer Science Department // +1 213-825-5683
	3531 Boelter Hall // Los Angeles, California 90024 // USA
	wales@LOCUS.UCLA.EDU     ...!(ucbvax,ihnp4)!ucla-cs!wales
Technical Details
Message-ID: <10252@ucla-cs.ARPA>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!hplabs!sdcrdcf!ucla-cs!wales

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbosgd!hplabs!sdcrdcf!ucla-cs!wales
From: wales@ucla-cs.ARPA (Rich Wales)
Newsgroups: net.lang.c++
Subject: Does 'inline' imply 'static'?
Message-ID: <10252@ucla-cs.ARPA>
Date: Fri, 28-Mar-86 14:32:31 EST
Article-I.D.: ucla-cs.10252
Posted: Fri Mar 28 14:32:31 1986
Date-Received: Sun, 30-Mar-86 03:22:19 EST
Reply-To: wales@ucla-cs.UUCP (Rich Wales)
Distribution: net
Organization: UCLA Computer Science Dept.
Lines: 34