Created the macros PRIzd and PRIzx to deal with MSVC lack of C99.

Thanks to Iain Denniston for pointing it out.
(cherry picked from commit 3a9ae348bcce79ee87633d0e302eae8d4719d587)
This commit is contained in:
Marcelo Roberto Jimenez 2011-03-11 17:20:17 -03:00
parent a1d7727903
commit a3683a3be0
3 changed files with 21 additions and 4 deletions

View File

@ -255,10 +255,17 @@ Version 1.8.0
Version 1.6.13
*******************************************************************************
2011-03-11 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
Created the macros PRIzd and PRIzx to deal with MSVC lack of C99.
Thanks to Iain Denniston for pointing it out.
2011-03-08 Iain Denniston <iain.denniston(at)gmail.com>
Fixes for headers when compiled under C++
2011-03-08 Iain Denniston <iain.denniston(at)gmail.com>
Fix for uuid_unpack incorrect shift precedence.
*******************************************************************************

View File

@ -34,14 +34,18 @@
/*
* UPNP_INLINE
* PRId64
* PRIzd
* PRIzu
* PRIzx
*/
#ifdef UPNP_USE_MSVCPP
/* define some things the M$ VC++ doesn't know */
#define UPNP_INLINE
typedef __int64 int64_t;
#define PRId64 "I64d"
#define PRIzd "ld"
#define PRIzu "lu"
#define PRIzx "lx"
#endif /* UPNP_USE_MSVCPP */
#ifdef UPNP_USE_BCBPP
@ -51,7 +55,9 @@
#warning The Borland C compiler is probably broken on PRId64,
#warning please someone provide a proper fix here
#define PRId64 "I64d"
#define PRIzd "zd"
#define PRIzu "zu"
#define PRIzx "zx"
#endif /* UPNP_USE_BCBPP */
#ifdef __GNUC__
@ -60,7 +66,9 @@
* runtime printf which ends up getting called, not the glibc
* printf, so it genuinely doesn't have "zu"
*/
#define PRIzd "ld"
#define PRIzu "lu"
#define PRIzx "lx"
#endif /* __GNUC__ */
#else
/*!
@ -93,13 +101,15 @@
/* #define PRId64 PRId64 */
/*!
* \brief Supply the PRIzu printf() macro.
* \brief Supply the PRIz* printf() macros.
*
* This macro was invented so that we can live a little longer with
* These macros were invented so that we can live a little longer with
* MSVC lack of C99. "z" is the correct printf() size specifier for
* the size_t type.
*/
#define PRIzd "zd"
#define PRIzu "zu"
#define PRIzx "zx"
#endif
/*

View File

@ -446,7 +446,7 @@ int http_SendMessage(SOCKINFO *info, int *TimeOut, const char *fmt, ...)
/* Copy CRLF at the end of the chunk */
memcpy(file_buf + num_read, "\r\n", 2);
/* Hex length for the chunk size. */
sprintf(Chunk_Header, "%zx", num_read);
sprintf(Chunk_Header, "%" PRIzx, num_read);
/*itoa(num_read,Chunk_Header,16); */
strcat(Chunk_Header, "\r\n");
/* Copy the chunk size header */
@ -850,7 +850,7 @@ int http_WriteHttpPost( IN void *Handle,
if (!tempbuf)
return UPNP_E_OUTOF_MEMORY;
/* begin chunk */
sprintf(tempbuf, "%zx\r\n", *size);
sprintf(tempbuf, "%" PRIzx "\r\n", *size);
tempSize = strlen(tempbuf);
memcpy(tempbuf + tempSize, buf, *size);
memcpy(tempbuf + tempSize + *size, "\r\n", 2);