字符串数组转换

lan*_*ng2 8 c ansi-c

我有以下代码:

char *array1[3] = 
{
    "hello",
    "world",
    "there."
};

struct locator_t
{
    char **t;
    int len;
} locator[2] =
{
    {
        array1,
        10
    }
};
Run Code Online (Sandbox Code Playgroud)

它用"gcc -Wall -ansi -pedantic"编译好.但是对于另一个工具链(Rowley),它抱怨

warning: initialization from incompatible pointer type
Run Code Online (Sandbox Code Playgroud)

在char**t的行上.这确实是非法的代码还是没问题?

谢谢你的回答.我现在知道我的问题在哪里.但是,它提出了一个新问题:

字符串数组初始化

Fre*_*Foo 4

对我来说似乎完全合法;char *[3]衰减为char **,因此分配应该有效。

GCC 4.4.5 和 CLang 1.1 都没有抱怨。