我想知道是否存在非数组不完整类型.
解决方法 供参考,什么是不完整的,完整的?At varIoUs points within a translation unit an object type may be
incomplete (lacking sufficIEnt information to determine the size of objects of that type) or complete (having sufficIEnt information). C11 §6.2.5 1
除了可能的struct,union,数组和总是voID之外,枚举暂时不完整,因为它们的大小不完整,直到}
… The enumerated type is incomplete until immediately after the
}
that terminates the List of enumerator declarations,and complete thereafter. C11 §6.7.2.2 4
int main() { enum ee1 { a1 = 0,b1 = sizeof(int),c1 }; printf("%zu\n",sizeof(enum ee1)); // OK // error: invalID application of 'sizeof' to incomplete type 'enum ee2' // v--------------v enum ee2 { a2 = 0,b2 = sizeof(int),c2 = sizeof(enum ee2) }; // Bad printf("%zu\n",sizeof(enum ee2)); // OK}
进一步
总结All declarations of structure,or enumerated types that have the same scope and use the same tag declare the same type. Irrespective of whether there is a tag or what other declarations of the type are in the same translation unit,the type is incomplete until immediately after the closing brace of the List defining the content,and complete thereafter. §6.7.2.3 4
以上是内存溢出为你收集整理的是否存在非数组不完整类型?全部内容,希望文章能够帮你解决是否存在非数组不完整类型?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)