delorie.com/archives/browse.cgi | search |
From: | Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: inline operator bug ? |
Date: | Fri, 04 May 2001 23:33:09 +0100 |
Lines: | 44 |
Message-ID: | <tma6ftk8trubptfjajlv6t70i33ca38vl3@4ax.com> |
References: | <9cs1p9$a0d$2 AT info DOT cyf-kr DOT edu DOT pl> |
NNTP-Posting-Host: | modem-120.californium.dialup.pol.co.uk |
Mime-Version: | 1.0 |
X-Trace: | news6.svr.pol.co.uk 989015572 31342 62.136.68.248 (4 May 2001 22:32:52 GMT) |
NNTP-Posting-Date: | 4 May 2001 22:32:52 GMT |
X-Complaints-To: | abuse AT theplanet DOT net |
X-Newsreader: | Forte Agent 1.7/32.534 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
"Rafal Maj" <maj_rafal AT poczta DOT onet DOT pl> wrote: > I have found some problems with using inline operators and I think that it > might be a bug. > This bug can only be seen in projects, so my example program has 3 files : > ****** file bug1lib.h ****** > class cA { public : inline void operator +(int); } ; > ****** file bug1lib.cc ******* > #include "bug1lib.h" > inline void cA::operator +(int) { }; > ****** bug1m.cc ****** > #include "bug1lib.h" > int main() { cA a; a+2; } > > After building this project I get output like this : > Compiling: bug1lib.cc no errors > Compiling: bug1m.cc no errors > Creating: bug1.exe > Error: bug1m.o: In function `main': > Error: bug1m.cc(.text+0x10): undefined reference to `cA::operator+(int)' > Error: collect2: ld returned 1 exit status > > After removing inline from bug1lib.cc & bug1lib.h everything is working > correct. This is expected behaviour. To be inlined, the function must be visible at compile time whenever it is used. So the code can either be: ****** file bug1lib.h ****** class cA { public : void operator +(int) {/*...*/} } ; ****** bug1m.cc ****** #include "bug1lib.h" int main() { cA a; a+2; } or: ****** file bug1lib.h ****** class cA { public : void operator +(int); } ; inline void cA::operator +(int) {/*...*/}; ****** bug1m.cc ****** #include "bug1lib.h" int main() { cA a; a+2; }
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |