HP C A.06.05 Reference Manual
Program Organization
Lexical Elements
Chapter 2 17
Semantics for the __thread keyword: Only variables of static duration can be thread specific.
Thread specific data objects can not be initialized. Pointers of static duration that are not
thread specific may not be initialized with the address of a thread specific object —
assignment is okay. All global variables, thread specific or not, are initialized to zero by the
linker implicitly.
Only one declaration, for example,
__thread int x;
is allowed in one compilation unit that contributes to the program (including libraries linked
into the executable). All other declarations must be strictly references:
extern __thread int x;
Even though __thread has the same syntax as a type qualifier, it does not qualify the type,
but is a storage class specification for the data object. As such, it is type compatible with
non-thread-specific data objects of the same type. That is, a thread specific data int is type
compatible with an ordinary int, (unlike const and volatile qualified int).
Note that use of the __thread keyword in a shared library will prevent that shared library
from being dynamically loaded (that is, loaded via an explicit call to shl_load()).
typedef
See “Typedef Declarations” on page 19.
union
See “Structure and Union Tags” on page 49.
unsigned
A data type modifier that indicates that no sign bit will be used. The data is assumed to
contain values greater than or equal to zero. All integer data types are signed by default. The
unsigned keyword can be used to modify these data types:
• char
• int
• enum
• long
• long long
• short