T
Tinku
look at this code .... i am quite confuse why i am getting error while
compiling it by gcc.
#include <stdio.h>
struct myStructure
{
int i;
static int si;
};
int main()
{
struct myStructure a;
printf("%u \n", sizeof(a));
printf("%u \n", sizeof(struct myStructure));
return 0;
}
sumit@programming$ gcc -Wall -Wextra -pedantic -ansi
static_inside_struct.c
error: expected specifier-qualifier-list before ‘static’
I dont understand why the error is coming while compiling it
cant we take static variable in structure or what ?
am i wrong some where?
if i remove static from the struct myStructure it works, but it is not
working with static variable
as we know static variable is stored somewhere else (in Data segment)
and auto variable is stored in stack (auto storage) , this is because
the error is coming ?
please teach me what exactly is being happened .
Thanks .
compiling it by gcc.
#include <stdio.h>
struct myStructure
{
int i;
static int si;
};
int main()
{
struct myStructure a;
printf("%u \n", sizeof(a));
printf("%u \n", sizeof(struct myStructure));
return 0;
}
sumit@programming$ gcc -Wall -Wextra -pedantic -ansi
static_inside_struct.c
error: expected specifier-qualifier-list before ‘static’
I dont understand why the error is coming while compiling it
cant we take static variable in structure or what ?
am i wrong some where?
if i remove static from the struct myStructure it works, but it is not
working with static variable
as we know static variable is stored somewhere else (in Data segment)
and auto variable is stored in stack (auto storage) , this is because
the error is coming ?
please teach me what exactly is being happened .
Thanks .