albert | 1 Jun 2003 16:00

2.9x to 3.2 static vars problems

I'm trying to compile with g++ 3.2 an application that compiles without
problems with 2.9x. The problem is with static varibles of classes. I've
got them defined outside the class:

	int Semaphore::key;

and inside the class:

	static int key;

but I get the following error:

	order.o(.bss+0x0): multiple definition of `Semaphore::key'
	main.o(.bss+0x0): first defined here

Any ideas of what I'm doing wrong?

Nathan Sidwell | 1 Jun 2003 16:36

Re: 2.9x to 3.2 static vars problems

albert <at> wickywicky.net wrote:
> I'm trying to compile with g++ 3.2 an application that compiles without
> problems with 2.9x. The problem is with static varibles of classes. I've
> got them defined outside the class:
> 
> 	int Semaphore::key;
> 
> and inside the class:
> 
> 	static int key;
> 
> but I get the following error:
> 
> 	order.o(.bss+0x0): multiple definition of `Semaphore::key'
> 	main.o(.bss+0x0): first defined here
> 
> Any ideas of what I'm doing wrong?
you have multiple definitions of Semaphore::key. I'm guessing you have the
out-of-class definition in a header file.

nathan

--

-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
          The voices in my head said this was stupid too
nathan <at> codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk


Gmane