cglm icon indicating copy to clipboard operation
cglm copied to clipboard

deprecated functions in io.h

Open offthebus opened this issue 3 years ago • 3 comments

io.h uses sprintf. VS2019 gives deprecated warnings as errors so the project will not build. I changed io.h to use sprintf_s which resolves the issue. I am not a github user really so I don't want to try committing this change. Thank you for this library, I am looking forward to trying it out.

offthebus avatar Nov 17 '22 17:11 offthebus

Could you tell how you did that? I'm getting 3 errors when changing all sprintf to sprintf_s in io.h. C2440 'function': cannot convert from 'float' to 'const char *const' Line 82 C2440 'function': cannot convert from 'float' to 'const char *const' Line 125 C2440 'function': cannot convert from 'float' to 'const char *const' Line 167

Jesse2431 avatar Nov 18 '22 08:11 Jesse2431

Hi, @offthebus, @Jesse2431

#define _CRT_SECURE_NO_WARNINGS should suppress those warnings. It is defined in cglm/common.h: https://github.com/recp/cglm/blob/master/include/cglm/common.h#L15-L17

Do you use latest version of cglm ?

recp avatar Nov 19 '22 17:11 recp

@recpt @offthebus

I'm having the same behaviour here. I have isolated it with this .c file:

test.c

#include <sys/types.h>
#include <cglm/cglm.h>

If you compile it with:

cl /c /Icglm/include test.c /MDd /W3

You 'll see the sprintf warnings.

I think the problem is this sys/types.h ends up including vcruntime.h, which is where the _CRT_INSECURE_DEPRECATE macro is defined, and your definition from common.h comes later in this case.

sacereda avatar Apr 17 '23 10:04 sacereda