c++ - 未记录的 GCC 扩展 : VLA in struct

标签 c++ memory gcc g++ variable-length-array

在阅读 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 会导致堆栈指针在调用函数的末尾恢复,在这种情况下它将是构造函数——而不是在封闭结构的末尾。

感谢您的帮助!

最佳答案

关于c++ - 未记录的 GCC 扩展 : VLA in struct,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12058760/

相关文章:

python - sess.run 动态增加内存使用量

c - 使用网络内核扩展监控网络数据包

c - 文件中的奇怪行为计数行

c++ - 作为类成员的通用 shared_ptr

c++ - 如何找到复杂多边形的面积 - C++

c++ - 在具有多个源文件的程序中的何处定义 CUDA 内核

c - 这个地址指向哪个函数?

c++ - 尝试打开文件并使用 vector 逐字复制

c++ - 尽管文件指针正确,但 fclose() 期间出现段错误

c++ - 嵌套类奇怪函数查找: surrounding class functions hide global functions