tags:

views:

49

answers:

1

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?

+4  A: 

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.

Potatoswatter
I get 'typedef ‘A’ is initialized (use `__typeof__` instead)'. I think Nathaniel is using g++.
Matthew Flaschen
@Matthew: `decltype` is the C++0x name for `__typeof__`. It might depend on flags or version.
Potatoswatter