Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: static vars and templates



hmm... interesting solution, but no, that is not what I was referring to.

my problem is with a template function which contains a static var.
if the function is called more then once then the linker complains about
multiple defined variable. I assume its a result of the .dylib not allowing
to put variables in a common area but that it only a wild guess.

this is a major headache :-(

btw, I'm using gcc-3.1

Yarden

>I had a real problem with static classes within template classes, which doesn't sound like what you are talking about.
>
>In my case, I had something of the form
>
>template <class F> class FOO
>{
> private:
> ....
> class BAR
> {
> public:
> int *p;
> }
> static BAR b;
> ...
>}
>
>The compiler didn't buy it (and wasn't helpful in narrowing down the problem). I finally worked around the problem by declaring the 'int *' as static.
>
>Regards,
>
>Justin
>
>On Sunday, December 22, 2002, at 02:21 PM, Yarden Livnat wrote:
>
>>Searching the archive I have found several posts about
>>the problem of a static var in templated code. However,
>>I haven't seen any answers or solutions (other then change
>>the code and define static vars outside the templated code.
>>
>>so, is there any solution ?
>>
>>thanks,
>>
>> Yarden
>>_______________________________________________
>>darwin-development mailing list | email@hidden
>>Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
>>Do not post admin requests to the list. They will be ignored.
>>
>--
>Justin C. Walker, Curmudgeon-At-Large *
>Institute for General Semantics | If you're not confused,
> | You're not paying attention
>*--------------------------------------*-------------------------------*
>_______________________________________________
>darwin-development mailing list | email@hidden
>Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
>Do not post admin requests to the list. They will be ignored.
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: static vars and templates (From: "Justin C. Walker" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.