You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于C标准中->运算符第一个操作数是否需指向完整结构体的技术问询

关于C标准中->运算符第一个操作数是否需指向完整结构体的技术问询

各位深耕C语言标准的大佬们,想请教一个关于C23标准里->运算符的细节问题:

先看这段代码:

struct s {
    int x;
    int y[sizeof((struct s*)0)->x];
};

C23标准的6.5.3.4p2条款给出了如下约束:

The first operand of the -> operator shall have type "pointer to atomic, qualified, or unqualified structure" or "pointer to atomic, qualified, or unqualified union", and the second operand shall name a member of the type pointed to.

我翻遍这段约束,都没看到要求->的第一个操作数必须指向完整的结构体类型的规定——那上面这段代码在C23标准框架下是合法的吗?

备注:内容来源于stack exchange,提问作者pmor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 16:18:17