Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#define _snprintf_s to snprintf

Tags:

c

visual-c++

I am porting a win32 app to linux and instead of having bunch of #ifdefs around every _snprintf_s, I was wondering if there is a way to #define it to snprintf somehow.

So something like -

#define _snprintf_s(1,2,3,4,5) snprintf(1,2,4,5)

The third parameter, Maximum number of characters to store, or _TRUNCATE is not present for snprintf.

Is this approach right? Can I do such a #define? If so, can someone maybe point out how I should go about it?

I went through this question to know I have to be careful about such #defines.

Thanks!

like image 314
sskanitk Avatar asked May 18 '26 20:05

sskanitk


1 Answers

#define _snprintf_s(a,b,c,...) snprintf(a,b,__VA_ARGS__)

like image 56
R.. GitHub STOP HELPING ICE Avatar answered May 21 '26 23:05

R.. GitHub STOP HELPING ICE