1

在阅读下面链接的 Niklas Frykholm 的非常好的博客文章时,我遇到了一些我无法完全理解的东西。

http://bitsquid.blogspot.nl/2012/01/sensible-error-handling-part-1.html

这段代码让我很困惑:

__THREAD Array<const char *> *_error_context_name;
__THREAD Array<const char *> *_error_context_data;

该代码定义了一个指向字符串数组的线程本地指针,该数组用作简单的堆栈。我不太明白的是如何以跨平台的方式初始化和销毁​​数组?此外,这如何与 dll 边界一起工作?

4

1 回答 1

1

Thread local only comments on where the variable resolves to in the program. You'd need to allocate it before using, just like any other variable.

You would want to do it when the thread started preferably, for the sake of sanity and performance.

于 2013-03-31T16:34:50.163 回答