Windows programming. Following the tutorial at this MS page and get to this line at the bottom:
TextOutW(hdc, 5, 5, greeting, wcslen(greeting));
Variable greeting
is a TCHAR array. VS2019 reports a warning (C4267) at the above line that there is a possible loss of data in the final parameter converting from the <size_t> returned by wcslen() and the int expected by TextOutW(). I know that the original example uses the _tcslen macro instead of wcslen() - it doesn't matter. I understand why that's happening but am completely mystified on how to modify the code to resolve the warning.
I can't find another TextOutx() that might take a <size_t>.
As an aside, while I was search for an answer, I read somewhere that strlen() is deprecated in 64-bit programming, although I can't recall where and I might have it wrong.
Is there a solution? Any advice?
An explicit cast to (int)wcslen(greeting);
resolves the warnings but hides the potential loss of data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.