小编0a0*_*2b9的帖子

clang:错误:从不兼容类型'int(*)[y] [z]'分配给'int(*)[y] [z]'

为什么clang(9.0.0)无法编译此代码?GCC(9.2.0)没问题。

使用typedef int arr[y][z]; arr *a;auto a = ...可以正常使用,但使用内联类型会产生奇怪的错误消息error: assigning to 'int (*)[y][z]' from incompatible type 'int (*)[y][z]'。这些类型对我来说看起来很兼容。两种不同的类型是否可能具有相同的语法?

#include <iostream>

int main() {
    int x, y, z;

    std::cin >> x >> y >> z;

    int (*a)[y][z];
    a = (int(*)[y][z]) new int[x * y * z];

    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            for (int k = 0; k < z; k++) …
Run Code Online (Sandbox Code Playgroud)

c++ gcc types clang

6
推荐指数
0
解决办法
54
查看次数

标签 统计

c++ ×1

clang ×1

gcc ×1

types ×1