我看到了这个链接
我在客户提供的库头文件中以以下方式定义了一系列enums
(我不能更改):
此外,这些枚举是稀疏的。
typedef enum
{
ERROR_NONE=59,
ERROR_A=65,
ERROR_B=67
}
我希望在我的函数中打印这些值,例如我想打印
ERROR_NONE
而不是 59
。是否有更好的方法仅使用 switch
case
或 if else
结构来完成这个任务?
示例: int Status=0;
/* some processing in library where Status changes to 59 */
printf("Status = %d\n",Status); /* want to print ERROR_NONE instead of 59 */