Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc error - typedef is initialized (use decltype instead)

Tags:

c

gcc

I'm compiling some C code, and I get the error

typedef 'A' is initialized (use decltype instead)

On one of my struct declarations. What could be causing this?

like image 980
Nathaniel Flath Avatar asked Oct 08 '10 19:10

Nathaniel Flath


1 Answers

I am able to reproduce that with the simple program

typedef int A = 3;

typedef declares an alias to a type; it does not declare a variable. So if you want an instance of struct my_struct named A, you cannot also have typedef struct my_struct { ... } my_struct in the same declaration.

like image 71
Potatoswatter Avatar answered Oct 09 '22 05:10

Potatoswatter