次のコードを検討してください。
enum
{
ERR_START,
ERR_CANNOTOPENFILE,
ERR_CANNOTCONNECT,
ERR_CANNOTCONNECTWITH,
ERR_CANNOTGETHOSTNAME,
ERR_CANNOTSEND,
};
char* ERR_MESSAGE[] =
{
[ERR_START] = "Nothing",
[ERR_CANNOTOPENFILE] = "Cannot open '%s' filename.\n",
[ERR_CANNOTCONNECT] = "Cannot connect.\n",
[ERR_CANNOTCONNECTWITH] = "Cannot connect with '%s'.\n",
[ERR_CANNOTGETHOSTNAME] = "Cannot get host name.\n",
[ERR_CANNOTSEND] = "Cannot send.\n",
};
このエラーを考えると:
error.h:27:1: error: parameter ‘ERR_MESSAGE’ is initialized
error.h:29:2: error: array index in non-array initializer
error.h:29:2: error: (near initialization for ‘ERR_MESSAGE’)
error.h:29:2: warning: initialization from incompatible pointer type
error.h:30:2: error: array index in non-array initializer
[....]
でコンパイルしてい-std=c99
ます。
これを修正する方法は?