双重枚举演员警告类型混合

时间:2013-06-13 09:26:33

标签: c casting enums compiler-warnings

我有以下C行代码,其中cfType是普通的C enum类型:

int foo (double * parameters) {
...
cfType coefSelect = (cfType) *parameters; /* The double pointed by at parameters
                                           * is cast to a cfType enum and result
                                           * is put in the var coefSelect.
                                           */
...
}

但是编译器会在演员阵容中发出“枚举类型与其他类型混合”的警告 - 但是演员不应该阻止此警告吗?

我在代码编辑器工作室使用德州仪器的C2000 C编译器

2 个答案:

答案 0 :(得分:6)

我认为你必须先投入一个整数类型来防止这种警告。

类似的东西:

cfType coefSelect = (cfType)(int) *parameters;

答案 1 :(得分:2)

尝试分两步进行投射:

cfType coefSelect = (cfType) (int) *parameters; 
相关问题