とりあえずtypedefの問題は「typedefは必ず先頭に付ける」という規則があれば解決できるね。
つまり
typedef int x; などはOK
int typedef x; などはNG
にすればよい。