2011-01-03 14:00:53 +00:00
|
|
|
// Wrapper for MSVC/GCC
|
2010-03-04 10:24:28 +00:00
|
|
|
#ifndef _STRINGS_WRAPPER_H
|
|
|
|
#define _STRINGS_WRAPPER_H
|
|
|
|
|
2011-01-03 14:00:53 +00:00
|
|
|
|
|
|
|
// For GCC, just use strings.h (this applies to mingw too)
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
# include <strings.h>
|
2011-01-10 20:47:48 +00:00
|
|
|
#elif defined(MSVC) || defined(_MSC_VER)
|
2011-01-03 14:00:53 +00:00
|
|
|
# pragma warning(disable: 4996)
|
|
|
|
# define strcasecmp stricmp
|
2015-08-11 20:50:22 +00:00
|
|
|
# if (_MSC_VER < 1900)
|
2015-12-18 08:39:40 +00:00
|
|
|
# include <stdio.h>
|
|
|
|
# include <stdarg.h>
|
|
|
|
# define snprintf c99_snprintf
|
|
|
|
# define vsnprintf c99_vsnprintf
|
|
|
|
/* see http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 */
|
|
|
|
inline int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
|
|
|
|
{
|
|
|
|
int count = -1;
|
|
|
|
|
|
|
|
if (size != 0)
|
|
|
|
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
|
|
|
|
if (count == -1)
|
|
|
|
count = _vscprintf(format, ap);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, format);
|
|
|
|
count = c99_vsnprintf(outBuf, size, format, ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
2015-08-11 20:50:22 +00:00
|
|
|
# endif
|
2010-06-28 09:45:42 +00:00
|
|
|
#else
|
2011-01-03 14:00:53 +00:00
|
|
|
# warning "Unable to determine your compiler, you should probably take a look here."
|
|
|
|
# include <strings.h> // Just take a guess
|
2015-12-18 08:39:40 +00:00
|
|
|
#endif
|
2010-03-04 10:24:28 +00:00
|
|
|
|
2011-01-03 14:00:53 +00:00
|
|
|
#endif /* _STRINGS_WRAPPER_H */
|