What's the deal with __thread?

Alex Rønne Petersen alex at lycus.org
Thu Nov 15 06:46:02 PST 2012


On 15-11-2012 15:42, Don Clugston wrote:
> On 15/11/12 11:54, Walter Bright wrote:
>> On 11/15/2012 2:28 AM, Don Clugston wrote:
>>> However, there is one case in the test suite which is unclear to me:
>>>
>>> extern(C) __thread int x;
>>>
>>> Is there any other way to do this?
>>
>> extern(C) int x;
>>
>
> What about extern(C) variables which are not thread local?
> (which I think would be the normal case).
> Then from a C header,
>
> extern(C) int x;
>
> must become:
>
> extern(C) __gshared int x;
>
> in D. It's a very rare case, I guess, but it's one of those situations
> where D code silently has different behaviour from identical C code.

I think most people are aware of this 'quirk' from what I've seen in 
binding projects, so it's probably not a big deal.

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d mailing list