How to get support for thread_local on Mac OSX clang?
Asked Answered
E

2

9

As shown in this answer, clang from Xcode on Mac OSX does not support thread_local storage even with C++11 flags set. Even on the latest version, Apple LLVM version 7.0.0 (clang-700.1.76), Target: x86_64-apple-darwin15.0.0, Thread model: posix, does not support thread_local:

../../src/dir/sysArch.h:1505:3: error: thread-local storage is not supported
                                       for the current target
  thread_local
  ^
Extramural answered 27/10, 2015 at 1:16 Comment(1)
You could use the open source version of clang instead? I am facing the same problem. In late 2016.Catastrophe
U
4

The version of clang supplied with Xcode 8 (and later) supports the thread_local keyword; see the discussion here.

Usurer answered 29/4, 2017 at 19:14 Comment(0)
T
1

You can use the old method of using pthread_getspecific() etc. to implement thread-local storage (or in Objective-C the NSThread's thread dictionary) if thread_local is not available in your compiler version.

Tonedeaf answered 15/2, 2020 at 10:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.