Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grammar and syntax of typedef in C language

Tags:

c

typedef

I have a problem with the typedef keywords in C language.

In my program, I use the following codes:

typedef int* a[10];

int main(){
 int a[10];
} 

they work well. But why there are no conflicts between a variable and a type sharing the same name a?

Regards.

like image 726
Summer_More_More_Tea Avatar asked Apr 06 '10 11:04

Summer_More_More_Tea


1 Answers

See msdn C language reference:

Typedef names share the name space with ordinary identifiers (see Name Spaces for more information). Therefore, a program can have a typedef name and a local-scope identifier by the same name.

like image 125
tanascius Avatar answered Nov 03 '22 21:11

tanascius