我有一段来自openCL内核的代码.
const uint idz = 100;
const uint idy = 100;
unit4 size_sino;
uint idz_p;
uint idy_p;
idz_p = (idz*size_sino.y+idy)/16;
idy_p = fmod((idz*size_sino.y+idy), (uint)16);
Run Code Online (Sandbox Code Playgroud)
当我编译内核时,发生了一些错误:
:192:18: error: call to 'fmod' is ambiguous
<stdin>:1078:48: note: candidate function
<stdin>:1084:49: note: candidate function
<stdin>:1079:49: note: candidate function
<stdin>:1080:49: note: candidate function
<stdin>:1081:49: note: candidate function
<stdin>:1082:49: note: candidate function
<stdin>:1083:50: note: candidate function
<stdin>:1085:50: note: candidate function
<stdin>:1086:50: note: candidate function
<stdin>:1087:50: note: candidate function
<stdin>:1088:50: note: candidate function
<stdin>:1089:51: note: candidate function
Run Code Online (Sandbox Code Playgroud)
fmod()是一个已经重载的内置函数.我理解两个输入的类型应该是相同的.谁能告诉我这里发生了什么?
jpr*_*ice 10
你fmod用两个uint参数调用.此函数具有for float和doublearguments的重载,因此编译器无法推断您希望使用哪个重载(因此有关模糊函数调用的错误).
您可以通过将参数强制转换为要使用的类型来明确表达您的意图:
idy_p = fmod((float)(idz*size_sino.y+idy), (float)16.f);
Run Code Online (Sandbox Code Playgroud)