warning C4996: 'strcpy': This function or variable may be unsafe. Consider...
Brought to you by:
pfusik
Warning in VS 2026 with toolset v145
_tcscpy(wav_filename + filenameChars, _T("wav"));
1>C:\jac\system\Windows\Programming\Repositories\RASTER-Music-Tracker\src\wasap.c(417,2): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
This is not a bug. MSVC's warning says "may be unsafe".
For many years, MSVC did not implement C99 - one had to stick to C89. Then they push for using these C11 functions which provide dubious safety - you need to pass the number of available characters.
I switched from MSVC to MinGW many years ago. Since you have already MSYS2 (for perl), installing MinGW GCC is as easy as:
Then:
Ok, I fixed some buffer overflows with malicious long filenames.
MSVC may still complain about "unsafe" functions, but I don't care.
I've added the _CRT_SECURE_NO_WARNINGS; define the project and the "unsafe" warnings are gone. But these two are still there and look valid to me:
C:\jac\system\Windows\Programming\Repositories\RASTER-Music-Tracker\src\asap.c(2813,24): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
1>C:\jac\system\Windows\Programming\Repositories\RASTER-Music-Tracker\src\asap.c(3991,10): warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup. See online help for details.
system\Windows\Programming\Repositories\RASTER-Music-Tracker\src\asap.c(4448,22): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss o
I will handle these. For now, just don't pass filenames consisting of over two billion characters. ;)
That is old days' Microsoft vs the rest of the world. The only SDK I know that didn't have
strdupwas early 2000s Windows Mobile - I remember I had to provide a (trivial) replacement for the missingstrdup. C23 finally has it officially: https://en.cppreference.com/w/c/string/byte/strdup.htmlFixed now.