On 20 April 2011 08:37, Boris Kolpackov wrote: > Hi, > > I am trying to figure out how to get a typedef hierarchy from the C/C++ > tree in GCC. Consider the following declarations: > > struct s {}; > > typedef s s_t; > typedef s_t my_s_t;
I don't know if GCC keeps the information you want, but according to the language rules there is no hierarchy. There's a type, and zero or more alternative names for it. The example above makes my_s_t a synonym for s, not s_t. Consider this valid code: typedef int foo; typedef int bar; typedef foo bar; typedef bar foo; What do you expect to see here? You want to track size_t, what if someone uses __typeof__(sizeof(1)), does that count? What about std::size_t? That could be defined as a synonym for __SIZE_TYPE__ or decltype(sizeof(1)) so is not in a sequence of typedef declarations that includes size_t.