public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Bug in g++ 4.1.2 when using inline function definied in cpp file but declared in h file
@ 2007-03-22  5:39 Bartosz Wadolowski
  2007-03-23  0:46 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Bartosz Wadolowski @ 2007-03-22  5:39 UTC (permalink / raw)
  To: gcc-bugs

hi
i found bug in g++ 4.1.2 - version included with new kubuntu fiesty.
to reproduce this bug i've created 3 simple files a.h, a.cpp and main.cpp

//a.h
#ifndef A_H
#define A_H
class A{
public:
	void b(int c);
private:
int d;
};
#endif 

//a.cpp
#include "a.h"
inline void A::b(int c)
{
	d = c;
}

//main.cpp
#include "a.h"
int main()
{
	A *a = new A;
	a->b(1);
	return 0;
} 


then when i'm compiling them :
g++ -c -o a.o a.cpp - everything is ok
g++ -o A a.o main.o - i get:

main.o: In function `main':
main.cpp:(.text+0x2f): undefined reference to `A::b(int)'
collect2: ld returned 1 exit status

when i add those 2 lines to a.cpp:
#pragma implementation
#pragma interface

so it looks like this:

//a.cpp
#include "a.h"
#pragma implementation
#pragma interface
inline void A::b(int c)
{
	d = c;
}

everything is ok. i tried every possible combination of those pragmas and 
inline kayword, but only this one seams to work.

bartosz wadolowski


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-23  0:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-22  5:39 Bug in g++ 4.1.2 when using inline function definied in cpp file but declared in h file Bartosz Wadolowski
2007-03-23  0:46 ` Jim Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).