1

While reading the very nice blog post by Niklas Frykholm linked below, I came across something I can't quite wrap my head around.

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

This code confused me:

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

The code defines a thread local pointer to an array of strings which is used as a simple stack. The thing I don't quite understand is how one would initialize and destroy the arrays in a cross-platform manner? Also how does this work with dll boundaries?

1 Answers1

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.

Tom Kerr
  • 10,444
  • 2
  • 30
  • 46
  • And if I declare this in a header file included by both a dll and the application are the pointers correctly resolved in a dll? As in, will they point to the same location as the main application? – Bas Zalmstra Mar 31 '13 at 19:27