Is &errno legal C?

后端 未结 5 979
南方客
南方客 2020-12-23 19:43

Per 7.5,

[errno] expands to a modifiable lvalue175) that has type int, the value of which is set to a positive error number by several library functio

5条回答
  •  臣服心动
    2020-12-23 20:04

    This seems like a valid implementation where &errno would be a constraint violation:

    struct __errno_struct {
        signed int __val:12;
    } *__errno_location(void);
    
    #define errno (__errno_location()->__val)
    

    So I think the answer is probably no...

提交回复
热议问题