Is “typedef” in between the type and the alias standard-conformant?

前端 未结 5 536
春和景丽
春和景丽 2021-02-06 20:59

I stumbled upon some code where the typedef keyword is in between the type and the alias name like in

int typedef INT;

It compiles

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-06 21:34

    If you look at 7.1/1 you see this grammar for decl-specifier:, which shows that a type-specifier and the typedef keyword fall at the same point in the grammar, allowing you to interchange them as in the question (although as an aside never write code like this, it's not idiomatic at all).

    decl-specifier:

    storage-class-specifier
    
    type-specifier
    
    function-specifier
    
    friend
    
    typedef
    

提交回复
热议问题