Tag: zos

不允许在类型“const int ** const”和“int **”之间初始化,为什么?

使用V1.8 z / OS XL C编译器,使用INFO(ALL)警告升级,我在下面代码的第4行收到以下警告: WARNING CCN3196 Initialization between types “const int** const” and “int**” is not allowed. 1 int foo = 0; 2 int *ptr = &foo; 3 const int * const fixed_readonly_ptr = ptr; 4 const int ** const fixed_ptr_to_readonly_ptr = &ptr; 我无法理解为什么我会收到这个警告。 如果我可以为指向const int(第3行)的const指针分配一个int指针,那么为什么我不能将int指针的地址分配给指向const int的指针的const指针? 我错过了什么? 请注意,上面的代码是一个精简的示例,只是显示了我在少量代码中遇到的问题。 真正的上下文是我有一个const指针指向struct(struct s ** const),并将它作为参数传递给函数,该函数的参数被定义为指向const结构的const指针(const […]