Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (26 sloc) 2.02 KB
title f1_keywords helpviewer_keywords ms.assetid
/GT (Support Fiber-Safe Thread-Local Storage)
/GT compiler option [C++]
GT compiler option [C++]
thread-local storage
static thread-local storage and fiber safety
-GT compiler option [C++]
fiber-safe static thread-local storage compiler option [C++]

/GT (Support Fiber-Safe Thread-Local Storage)

Supports fiber safety for data allocated using static thread-local storage, that is, data allocated with __declspec(thread).




Data declared with __declspec(thread) is referenced through a thread-local storage (TLS) array. The TLS array is an array of addresses that the system maintains for each thread. Each address in this array gives the location of thread-local storage data.

A fiber is a lightweight object that consists of a stack and a register context and can be scheduled on various threads. A fiber can run on any thread. Because a fiber may get swapped out and restarted later on a different thread, the address of the TLS array must not be cached or optimized as a common subexpression across a function call (see the /Og (Global Optimizations) option for details). /GT prevents such optimizations.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.

  2. Click the C/C++ folder.

  3. Click the Optimization property page.

  4. Modify the Enable Fiber-safe Optimizations property.

To set this compiler option programmatically

  • See xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.EnableFiberSafeOptimizations%2A.

See also

MSVC Compiler Options
MSVC Compiler Command-Line Syntax

You can’t perform that action at this time.