warning: narrowing conversion of '(stride * 4u)' from 'unsigned int' to 'WORD {aka short unsigned int}' inside { } is ill-formed in C++11 [-Wnarrowing]
I cannot figure out why I am getting this warning compiling the following code from MinGW:
unsigned stride = 3;
D3DVERTEXELEMENT9 NORMALELEMENT =
{ 0, stride * sizeof(gs_scalar), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 };
if (useNormals) stride += 3;
It is complaining about the stride * sizeof(gs_scalar)
(gs_scalar is float
) inside those braces, but I do not see how this is a narrowing conversion since sizeof
returns the number of bytes. I tried changing stride
's data type to WORD, DWORD, CHAR, everything, but I keep getting the same or similar warning.
stride * sizeof(gs_scalar)
in an explicit cast if that's your intention? – goji