recp / cglm

📽 Highly Optimized 2D / 3D Graphics Math (glm) for C
MIT License
2.33k stars 231 forks source link

Visual Studio 2022 C17 Compiler unsafe sprintf error C4996 #415

Closed adotspooner closed 6 months ago

adotspooner commented 6 months ago

Hi :) I get the following error with my project settings in Visual Studio 2022 with the C17 Compiler. I would like to let this security warning feature enabled, maybe cglm could upgrade to the secure versions of the print functions?

Error C4996 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. 
To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
cglm-0.9.4\include\cglm\io.h    135
recp commented 6 months ago

Hi @adotspooner,

Thanks for reporting this, https://github.com/recp/cglm/commit/eb3a51e591c1abc8a55af8409eaae119ee2bb3a9 should do the job. IIRC, sprintf_s is not standard below C11 so snprintf() is enough for now, I think.

adotspooner commented 6 months ago

Hi @recp,

thank you for this ultra fast response, I will build cglm with this commit tomorrow and try it with my VS project.

adotspooner commented 6 months ago

Hi @recp, I tested my code with the build of the master branch at eb3a51e and I could remove the _CRT_SECURE_NO_WARNINGS without getting errors. Thank you again!

recp commented 6 months ago

@adotspooner great to hear that!

Thanks