Compile error ( error: 'vsprintf_s' was not declared in this scope )
I tried to compile "controllgallery2.nim" , but ..
Error: execution of an external compiler program 'gcc.exe -c -w -mno-ms-bitfields -IC:\Users\(User name)\Documents\Language\Nim\nim-0.18.0\lib -o G:\Nim \nimcache\win_debug.cpp.obj C:\Users\(User name)\.nimble\pkgs\ui-0.9.2\ui\./libui/windows\debug.cpp' failed with exit code: 1 C:\Users\terur\.nimble\pkgs\ui-0.9.2\ui\./libui/windows\debug.cpp: In function 'void realbug(const char*, const char*, const char*, const char*, con st char*, va_list)': C:\Users\(User name)\.nimble\pkgs\ui-0.9.2\ui\./libui/windows\debug.cpp:76:31: error: 'vsprintf_s' was not declared in this scope vsprintf_s(msg, n, format, ap); ^
What I should do to fix that error? (Sorry for my poor English..)
Pretty sure this is an issue with libui:
https://github.com/andlabs/libui/issues/259
The root as I understand it is that vsprintf_s is a more secure version of the original vsprintf but it's a Microsoft extension only present in vcc, meaning it fails to compile with gcc/mingw. You can monkey patch this to fix it locally:
-
Go wherever you have nimble installing your packages
Windows default:
C:\Users\<USER>\.nimble\pkgsUnix default:~/.nimble/pkgs -
Go to
ui-<version>\ui\libui\windows -
Open
debug.cppand comment out line 76:-vsprintf_s(msg, n, format, ap); +// vsprintf_s(msg, n, format, ap);
This will solve that error, but there are more of these in libui:
- utf16.cpp:59
wcscpy_s - utf16.cpp:90
vswprintf_s
This is still happening, libui issue is closed as resolved: https://github.com/andlabs/libui/issues/259
@kidandcat it doesn't appear to be closed yet per the issue status and the latest comment from the dev. The safe string functions mentioned here will still likely cause these errors.