c++ - Warning C4267 'argument': conversion from 'size_t' to 'DWORD', possible loss of data -
i migrating code 32bit vs2012 64bit vs2015.
i encountered following function call in program:
crypthashdata(hhash, (byte*)auth_encryption_key, wcslen(auth_encryption_key) * sizeof(wchar_t), 0u))
whose declaration in wincrypt.h
located in c:\program files (x86)\windows kits\8.0\include\um\wincrypt.h
(looks not edited).
the declaration is:
winadvapi bool winapi crypthashdata( _in_ hcrypthash hhash, _in_reads_bytes_(dwdatalen) const byte *pbdata, _in_ dword dwdatalen, _in_ dword dwflags );
dword dwflags: problem here
0u
unsigned int , function needsdword
.
to solve error did:
c-style
casting(dword)(0u)
in functioncall(tried size_t, unsigned int)
static_cast
- tried creating new variable , casted it
but warning still persists
looks have change in function call
can suggest me how solve issue.
please ask if more details required.
you thinking of 0u being problem.
me looks problem should around third parameter, size_t value used feed dword parameter.
as someprogrammerdude has explained, size_t 64bit in new environment, while dword 32bit. explains mismatch on new platform.
on 32bit platform did not warning (i assume), because size_t 32bit there, without risk of loosing information.
you reported casting avoids warning, indicates 0u
not problem.
fact warning seems on line 0u
caused compiler complaining whole function call , pin pointing end of it, i.e. closing )
, happens on same line 0u
.
experiment of moving )
separate lines (result visible difference bwetween 2 screenshots) has confirmed this.
note casting avoided warning, not same solving problem.
(you wisely asked safety of casting, recommend in separate question.)
Comments
Post a Comment