typedef a struct before it's declared

前端 未结 7 1889
死守一世寂寞
死守一世寂寞 2020-12-09 15:14

I\'m not a beginner, I\'m very familiar with the following idiom:

typedef struct Foo_ Foo;// I know typedef struct Foo Foo is fine, I\'m just trying to make          


        
相关标签:
7条回答
  • 2020-12-09 15:55

    It's called forward declaring. The forward declaration allows you to use its name in context where an incomplete type is allowed.

    The compiler will "see" the typedef tag, and store it away until the type is found, so as long as you have the type declared in there after the typedef, but before any usage, it's fine.

    0 讨论(0)
提交回复
热议问题