Im getting an error: register name not specified for 'i

#include <stdio.h>
register int i = 10;
int main(void)
{
    printf( " i = %d \n ", i );
    return 0;
}

Here I declared the variable i as register. But compiling it showing the following error

" error: register name not specified for ‘i’ "

Why shouldn't we use the register keyword globally?

+3
source share
3 answers

A registervariable is a type of local variable.
This is a hint for storing a value in a register for faster access.
A register variable cannot be global or static.
It can only be defined in a block.
Also, please format the code you publish

+10
source

A register , , . register , , , , . , .

, , , . , , register . , , / .

+2

register . .

, , , , . , , , , , , "" .

, register . register, , ( , ). register , "stack". , static extern.

, register , . - promises - .

-3

Source: https://habr.com/ru/post/1783387/


All Articles