wren-lang / wren

The Wren Programming Language. Wren is a small, fast, class-based concurrent scripting language.
http://wren.io
MIT License
6.85k stars 549 forks source link

sprintf & vsprintf deprecation errors when building in visual studio 2022 #1092

Open Aeva opened 2 years ago

Aeva commented 2 years ago

Here's the full error output. I dropped the sources into a C++17 project, configured the include paths, and hit build.

1>C:\Users\aeva\Projects\tangerine\third_party\wren\src\vm\wren_compiler.c(431,16): error C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\Users\aeva\Projects\tangerine\third_party\wren\src\vm\wren_compiler.c(432,13): error C4996: 'vsprintf': This function or variable may be unsafe. Consider using vsprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\Users\aeva\Projects\tangerine\third_party\wren\src\vm\wren_compiler.c(484,7): error C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\Users\aeva\Projects\tangerine\third_party\wren\src\vm\wren_compiler.c(488,7): error C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\Users\aeva\Projects\tangerine\third_party\wren\src\vm\wren_compiler.c(4121,3): error C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Aeva commented 2 years ago

the _s forms look to be introduced in C11 though, so I'm guessing you don't want a PR that replaces them?

nitz commented 2 years ago

I'm thinking you're probably right that targeting C99/C++98 is a desired feature (at least it's mentioned on the home page)

Looks like the premake script defines _CRT_SECURE_NO_WARNINGS, and the 2017, 2019 projects have it defined.

You should be okay to define _CRT_SECURE_NO_WARNINGS for at least your third_party\wren directory.

All that said, I too wanted vs2022 project files, so I updated premake and generated them here.