Community
cancel
Showing results for 
Search instead for 
Did you mean: 
John_M_Intel6
Employee
203 Views

thread_local error #1897 cannot be dynamically initialized

Hi - I was trying to use some code on StackOverflow for a 'thread on exit' function, but it wouldn't compile:

http://stackoverflow.com/questions/20112221/invoking-a-function-automatically-on-stdthread-exit-in-c...

So I tried something simpler, and got the same problem:

#include <iostream>

class Test {
public:
  ~Test() {
    std::cout << "exit" << std::endl;
  }
};

thread_local Test aTest;

The error message is:

error #1897: thread-local variable cannot be dynamically initialized

Should it compile? This is Intel C++ 16.0, in Windows Visual Studio Pro 2012, with C++11 enabled.

0 Kudos
4 Replies
Melanie_B_Intel
Employee
203 Views

Dynamic thread_local variables require library support.  Microsoft added this support in vs2015.   If you'd like to use this feature please get the latest Intel 16.0 compiler (currently, update 1) to use with vs2015.

--Melanie 

John_M_Intel6
Employee
203 Views

Hi Melanie - as I mentioned at the bottom of my post, I am using Intel C++ 16.0.

Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.1.146 Build 20151021

is there something else I need?

John

John_M_Intel6
Employee
203 Views

Sorry - ignore my last reply. I'll try to update VS...

John_M_Intel6
Employee
203 Views

Managed to update to VS2015 (eventually - required re-installation of Parallel Studio) and code now builds; thanks

Reply