thread_local std::vector error

C++ Builder XE4

this code give the error
E2461 'TempOptions' requires run-time initialization/finalization

 
static __thread std::vector <int> TempOptions;


what should i do ?

for now im using a pointer with realloc instead of a vector


edit :

MS Visual studio 2012 give a more understandable error,
it say that stuff with constructor cannot be declared thread_local

Last edited on
Note that thread_local is a keyword since C++11. I checked it and there are no problem with std::vector.

You probably need to update your compiler or allow C++11.

By the way: thread_local implies static. So you may omit it.
the last version i have is RAD Studio 10.3.3 and it support C++ 11
but it still give the same error even if i activate the option to use the new Clang compiler
C++ Builder even if it is the latest version (XE4 is from 2013) isn't really a good standalone C++ compiler. Too many non-standard tweaks under the hood to make the RAD work.

I used to use C++Builder -- and Delphi -- a lot when it was still Borland, before Embarcadero bought 'em out. RAD is great for creating quick GUI app templates, not so good with "pure" C++ code. But I've tried later versions and IMO they've gotten worse when it comes to straight forward C++ compatibility.

There are several Windows-based compilers/IDEs available for free that are more current C++ standards compliant: Visual Studio 2019 Community or Code::Blocks.

There are free Community versions of C++ Builder and Delphi available so you can continue using the IDE.
https://www.embarcadero.com/products/cbuilder/starter

FYI, I tried to install C++ Builder and Delphi Community on my Win10 development machine and both stalled out a fraction of the way through the install process.
Topic archived. No new replies allowed.