gcc警告:指针类型不兼容

时间:2013-05-20 19:21:09

标签: c gcc gcc-warning

在我的代码中,我有:

char DRAW_EX[DRAW_HEIGHT][DRAW_WIDTH] = {
        "*     *",
        " *   * ",
        "   *   ",
        " *   * ",
        "*     *"
           };
char DRAW_CIRCLE[DRAW_HEIGHT][DRAW_WIDTH] = {
        "  ***  ",
        " *   * ",
        "*     *",
        " *   * ",
        "  ***  "
           };
char DRAW_EMPTY[DRAW_HEIGHT][DRAW_WIDTH] = {
        "       ",
        "       ",
        "       ",
        "       ",
        "       "
           };

给我警告的那条线是:

char** leftDraw;
leftDraw = board[i][0]==EMPTY?DRAW_EMPTY:(board[i][0]==SHAPE_O?DRAW_CIRCLE:DRAW_EX);

警告是:

warning: assignment from incompatible pointer type [enabled by default]

我做错了什么?

1 个答案:

答案 0 :(得分:5)

  

我做错了什么?

您正尝试将char (*)[DRAW_WIDTH]分配给char**。这些是不兼容的类型。

声明

char (*leftDraw)[DRAW_WIDTH];

并且编译器会对该行感到满意。