What's the deal with __thread?

Walter Bright newshound2 at digitalmars.com
Thu Nov 15 11:35:59 PST 2012


On 11/15/2012 6:42 AM, 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;

That's right. extern(C) doesn't change the storage class.

> 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.



More information about the Digitalmars-d mailing list