Fix compiler warning with XCode. Thanks Matthias
Use thread_local only if GCC > 4.8