我遇到了以下代码,它以非标准的方式声明了char *
数组C
:
/* Message Type description array */
char *msgType[M_LAST_MSG] =
{
[M_INIT_MSG] "Init",
[M_RESET_MSG] "Serdes Reset"
};
Run Code Online (Sandbox Code Playgroud)
M_INIT_MSG
,M_RESET_MSG
并且M_LAST_MSG
是相应值为0,1和2的枚举.根据正式C
文档,此数组中的变量是字符串(文字),那么以这种方式使用这些枚举的目的是什么,是否有任何文档来支持它吗?
用ARM gcc
编译器编译gcc-arm-none-eabi
.