Tag: 限定符

C中的双指针const正确性警告

指向非const数据的指针可以隐式转换为指向相同types的const数据的指针: int *x = NULL; int const *y = x; 添加额外的const限定符以匹配额外的间接参数应该在逻辑上以相同的方式工作: int * *x = NULL; int *const *y = x; /* okay */ int const *const *z = y; /* warning */ 然而,用GCC或Clang编译这个与-Wall标志,会导致以下警告: test.c:4:23: warning: initializing 'int const *const *' with an expression of type 'int *const *' discards qualifiers in nested pointer types […]