offsetof at compile time

前端 未结 3 1867
情歌与酒
情歌与酒 2020-12-09 13:05

Is there a way of finding the offset of a member of a structure at compile-time? I wish to create a constant containing the offset of a structure member. In the following co

3条回答
  •  鱼传尺愫
    2020-12-09 13:48

    If you have a #include as I assume (the error message you cite without would be meaningless), it is a bug in your compiler. offsetof result is an integer constant expression in C99 as well as in C90.

提交回复
热议问题