05-11-2012, 02:09 AM
In case anyone decides to use MinGW to compile HPL1/OALWrapper, you may have found that the version of swprintf provided with MinGW takes three arguments, omitting the size of the buffer. The four argument function exists in MinGW, but it is under a different name. To remedy this I created the following header:
Then anywhere that the functions are used, I add the following to the header file:
Feel free to provide feedback or criticisms of my method. Hopefully this will be of use to anyone using MinGW.
PHP Code:
#ifndef MINGW_FUNCTION_DECL_H
#define MINGW_FUNCTION_DECL_H
#ifdef __MINGW32__
#include <cstring>
#include <cstdarg>
#include <cwchar>
inline int swprintf(wchar_t *buf, size_t length, const wchar_t *fmt, ...)
{
va_list args;
int i;
va_start(args, fmt);
i=_vsnwprintf(buf,length,fmt,args);
va_end(args);
return i;
};
inline int vswprintf(wchar_t *buf, size_t length, const wchar_t *fmt, va_list args)
{
return _vsnwprintf(buf,length,fmt,args);
}
#endif //__MINGW32__
#endif //MINGW_FUNCTION_DECL_H
PHP Code:
#ifdef __MINGW32__
#include "../MinGW_function_declarations.hpp" //May be a different path depending on project.
#endif
Feel free to provide feedback or criticisms of my method. Hopefully this will be of use to anyone using MinGW.