Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C typedef in declaration

typedef long a;
extern a int c;

Hi the above code gives errors like In function 'main': Line 7: error: two or more data types in declaration specifiers

but when the same 'a' in 2nd line is replaced by long it works perfectly fine. This works perfectly fine

typedef long a; extern long int c;

Please explain why does this happen

like image 563
surajd Avatar asked Aug 25 '26 18:08

surajd


1 Answers

long int is a type name.

type-alias-name type-name is parsed as two types even if type-alias-name is an alias for long and type-name is int.

like image 65
ouah Avatar answered Aug 28 '26 09:08

ouah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!