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

前端 未结 4 1437
忘掉有多难
忘掉有多难 2021-02-19 14:56

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:37

    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."

提交回复
热议问题