消息"在GCC 4.4中传递具有灵活数组成员的结构的ABI"是否重要?

Mel*_*lon 5 c compiler-construction gcc

我想知道来自编译器的这个消息是否应该仔细考虑.

我们来看看以下代码:

struct s
{
  int a;
  int b[];
};

void fun(struct s c)
{
}

int main()
{
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

这给出了以下错误:

main.c:7:6: note: the ABI of passing struct with a flexible array member has changed in GCC 4.4
Run Code Online (Sandbox Code Playgroud)

我的问题是:在更大的项目中安全使用这种结构吗?这种结构可能带来的风险和影响是什么(除了编译器消息)?

小智 -2

  1. 关于内存,每次我们调用该函数时都会创建结构变量,因此浪费内存。
  2. 确认您的项目中是否需要 struct sc 或 struct s &c 。