我有以下 C 代码行,其中 cfType 是普通的 C 枚举类型:
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.
*/
...
}
但是编译器在强制转换行发出警告“枚举类型与另一种类型混合”——但是强制转换不应该阻止这个警告吗?
我在 code composer studio 中使用 Texas Instruments 的 C2000 C 编译器
最佳答案
我认为你必须先转换成整数类型才能防止出现此警告。
类似于:
cfType coefSelect = (cfType)(int) *parameters;
关于c - Double to enum cast 警告类型混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17083596/