Is using sizeof on a variable where a type of the same name exists well defined?

前端 未结 4 1874
既然无缘
既然无缘 2021-02-19 15:04

Is this well defined behaviour or is it undefined / somehow else defined which foo (data type or identifier) sizeof will be operating on ?



        
4条回答
  •  余生分开走
    2021-02-19 15:42

    The local char foo completely hides typedef int foo in its scope. You cannot observe the name foo once it is hidden. Try creating a second typedef foo foo_t, or renaming something to avoid the "collision."

提交回复
热议问题