I am currently trying to compile a library for MacOS that was originally written for Windows. This library’s source makes use of lots of Windows secure functions like sscanf_s(), _snprintf_s(), fscanf_s()
Obviously, clang is having a hard time recognising these functions.
Note: This library is still in use by other people in my team so I cannot just haphazardly replace all these functions from the code.
I tried writing macros to replace these functions with more standard fucntions like so:
#define _snprintf_s(buffer, size, count, format, ...) snprintf(buffer, size, format, VA_ARGS)
#define sscanf_s sscanf
but the format args used by scanf functions are weird to write macros for since they are in this pattern:
format_arg1, size[if format_arg1 is string], format_arg2, format_arg3, size[if format_arg3 is string] ... so on ...
I have considered the following solutions:
- Writing a macro to catch these windows functions.
- defining functions that do the same thing and wrapping it around an ifdef for my use.
I am open to other solutions too, Thanks!