Storage-class specifiers
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
auto- автоматическая с длительностью никакой связи.Original:auto- automatic duration with no linkage.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.register- автоматическая с длительностью никакой связи. Также подсказки компилятору разместить переменную в регистре процессора.Original:register- automatic duration with no linkage. Also hints to the compiler to place the variable in the processor's register.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.static- статическая продолжительность внутренних связей.Original:static- static duration with internal linkage.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.extern- статическая продолжительность с внутренней или чаще внешних связей.Original:extern- static duration with either internal or more usually external linkage.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions._Thread_local- (начиная с C11) - резьба срок хранения.Original:_Thread_local- (начиная с C11) - thread storage duration.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Содержание |
[править] Объяснение
[править] Хранение продолжительности
Все переменные в программе есть одна из следующих длительности хранения, что определяет его жизнь
Original:
All variables in a program have one of the following storage durations that determines its lifetime:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- ' 'Автоматические длительности хранения. Переменных выделяется в начале ограждающих блоков кода и освобожден в конце. Это значение по умолчанию для всех переменных, кроме тех, заявил
static,externили_Thread_local.Original:automatic storage duration. The variable is allocated at the beginning of the enclosing code block and deallocated at the end. This is the default for all variables, except those declaredstatic,externor_Thread_local.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- ' 'Статической длительности хранения. Переменную выделяется при запуске программы и освобождаются, когда программа заканчивается. Только один экземпляр переменной может существовать. Переменные, объявленные с
staticилиexternэту длительность хранения.Original:static storage duration. The variable is allocated when the program begins and deallocated when the program ends. Only one instance of the variable can exist. Variables declared withstaticorexternhave this storage duration.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- ' 'Поток длительность хранения (начиная с C11). Переменную выделяется, когда поток начинает и освобождается, когда поток завершается. Каждый поток имеет свой собственный экземпляр переменной. Только переменные, объявленные
_Thread_localэту длительности хранения._Thread_localможет быть объявлен только для переменных, объявленных сstaticилиexternи не может быть использован в объявлении функции.Original:thread storage duration (начиная с C11). The variable is allocated when the thread begins and deallocated when the thread ends. Each thread has its own instance of the variable. Only variables declared_Thread_localhave this storage duration._Thread_localcan only be declared for variables declared withstaticorexternand cannot be used in a function declaration.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- ' 'Выделено длительности хранения. Переменную выделяется и освобождается по запросу с помощью функции динамического распределения памяти.Original:allocated storage duration. The variable is allocated and deallocated per request by using динамического распределения памяти functions.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[править] Связь
Связь относится к способности переменной или функции должен быть передан в других областях. Если переменная или функция с тем же идентификатором объявлена в нескольких областях, но не могут быть отнесены к не все из них, а затем несколько экземпляров переменной создаются. Следующие связи признаются:
Original:
Linkage refers to the ability of a variable or function to be referred to in other scopes. If a variable or function with the same identifier is declared in several scopes, but cannot be referred to from all of them, then several instances of the variable are generated. The following linkages are recognized:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
- ' 'Никакой связи. Переменная может быть передан только из сферы это дюйма Все переменные с автоматической, резьба и динамические длительности хранения есть эта связь.Original:no linkage. The variable can be referred to only from the scope it is in. All variables with automatic, thread and dynamic storage durations have this linkage.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- ' 'Внутренней связи. Переменная может быть отнесено к из всех областей в текущей единице перевода. Все переменные, которые объявлены
staticэту связь.Original:internal linkage. The variable can be referred to from all scopes in the current translation unit. All variables which are declaredstatichave this linkage.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- ' 'Внешних связей. Переменная может быть отнесено к любой другой единицы трансляции во всей программе. Все переменные, которые объявлены либо
externилиconstбез явного хранения спецификатора класса, но неstatic, имеют эту связь.Original:external linkage. The variable can be referred to from any other translation units in the entire program. All variables which are declared eitherexternorconstwith no explicit storage-class specifier, but notstatic, have this linkage.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[править] Ключевые слова
auto, register, static, extern, _Thread_local
[править] Пример
| Этот раздел не завершён |