Article View: gnu.g++.bug
Article #406re: static functions
From: Tom Keffer
Date: Sun, 10 Sep 1989 17:11
Date: Sun, 10 Sep 1989 17:11
63 lines
2353 bytes
2353 bytes
mt> Date: Sat, 9 Sep 89 19:07:32 PDT
mt> From: tiemann@Sun.COM (Michael Tiemann)
mt> Reply-To: tiemann@lurch.stanford.edu
mt> Date: Sat, 9 Sep 89 16:51:31 PDT
mt> From: keffer@sperm.ocean.washington.edu (Tom Keffer)
mt> Michael,
mt> This goes back to an earlier discussion we had as to whether
mt> -finline-functions should be the default. Consider the following:
mt> #ifdef DEBUG
mt> #define Inline static
mt> #else
mt> #define Inline inline
mt> class Foo {
mt> void bar();
mt> };
mt> Inline bar() { /* a definition */ }
mt> Is what you really mean ``Inline void Foo::bar ();''.
Yes, of course. Sorry.
mt> If so I don't
mt> see a problem with just #defining ``Inline'' to nothing, since the
mt> return type will save your function from not having a return type.
mt> Michael
Sorry, I didn't make myself very clear. All of the above code is in a
header file. The intention is to make the definition of Foo::bar a
static function when debugging, inline when not. If you don't make it
static, the linker will complain about multiple definitions.
Maybe there's a better way of doing this but, in any case, the two
compilers (cfront 2.0 and g++) handle this case differently.
Consider:
class Foo {
STATIC void bar();
};
static void Foo::bar() { }
cfront 2.0 will declare an error if STATIC is #defined to nothing, g++
will not.
Again, the cavaet. This is being passed on from a user of my vector
package. I have not verified it first hand.
-tk
---
Dr. Thomas Keffer | Internet: keffer@sperm.ocean.washington.edu
School of Oceanography | BITNET: keffer%sperm.ocean.washington.edu@UWAVM
Univ. of Washington, WB-10 | uucp: uw-beaver!sperm.ocean.washington.edu!keffer
Seattle, WA 98195 | Telemail: T.KEFFER/OMNET
(206) 543-6455
Technical Details
Message-ID:
<8909101711.AA14686@sperm.ocean.washington.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!SPERM.OCEAN.WASHINGTON.EDU!kefferReferences:
<8909100207.AA06064@teacake.sun.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!SPERM.OCEAN.WASHINGTON.EDU!keffer From: keffer@SPERM.OCEAN.WASHINGTON.EDU (Tom Keffer) Newsgroups: gnu.g++.bug Subject: re: static functions Message-ID: <8909101711.AA14686@sperm.ocean.washington.edu> Date: 10 Sep 89 17:11:07 GMT References: <8909100207.AA06064@teacake.sun.com> Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 63