(ANSI-C 89)
Hi, is it possible to declare a variable both static and register ? When ever I try to do this I just get as an error massage: multiple storage classes in declaration specifiers
This is the code:
#include <stdio.h>
void f1(static int i);
int main()
{
static register int i;
i = 5;
f1(i);
}
void f1(static int i)
{
static int y =6;
y+=1;
printf("\n Y=%d \n",y);
}
and th
Both register
and static
are storage class specifiers, and at most one storage class specifier can be specified.
From the C11 Standard ISO/IEC 9899:2011:
6.7.1 Storage-class specifiers
Syntax
- storage-class-specifier:
typedef
extern
static
_Thread_local
auto
register
Constraints
- At most, one storage-class specifier may be given in the declaration specifiers in a declaration, except that
_Thread_local
may appear withstatic
orextern
.120)
120)See ‘‘future language directions’’ (6.11.5).