在阅读 Clang 文档时,我发现了以下有趣的花絮:[1]
clang does not support the gcc extension that allows variable-length arrays in structures. This is for a few reasons: one, it is tricky to implement, two, the extension is completely undocumented, and three, the extension appears to be rarely used. Note that clang does support flexible array members (arrays with a zero or unspecified size at the end of a structure).
如何使用此扩展程序?我的理解是,在构造函数中使用 alloca 会导致堆栈指针在调用函数的末尾恢复,在这种情况下它将是构造函数——而不是在封闭结构的末尾。
感谢您的帮助!
最佳答案
见 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37428
还有http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42121
是的,这很奇怪。
关于c++ - 未记录的 GCC 扩展 : VLA in struct,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12058760/