This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

main() as your friend ?



Hello there,

I'm a bit confused why the following C++ code doesn't link on RedHat Linux
5.1 on Alpha EV5.6 for snapshot 981109

# include <iostream.h>

struct S
{
public:
	S();
	friend int main();
private:
	int a;
};

S::S()
{
	a = 0;
};

S b;

int
main()
{
	cout << b.a << '\n';
	return 0;
}

I get
	
/usr/lib/crt1.o: In function `_start':
../sysdeps/alpha/elf/start.S:77: undefined reference to `main'
../sysdeps/alpha/elf/start.S:77: undefined reference to `main'
collect2: ld returned 1 exit status


Regards

David C Binderman MSc BSc	+44 1293 534847		dcb@pncl.co.uk



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]