[Spice-devel] [vdagent-win PATCH] fix format string for Visual Studio
Frediano Ziglio
fziglio at redhat.com
Mon Jul 24 15:44:25 UTC 2017
>
> The "z" size specifier is not supported by Visual Studio.
> Use "I" if Visual Studio is detected.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> vdagent/desktop_layout.cpp | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
> index 11ad009..3272be5 100644
> --- a/vdagent/desktop_layout.cpp
> +++ b/vdagent/desktop_layout.cpp
> @@ -17,6 +17,16 @@
>
> #include <spice/qxl_windows.h>
> #include <spice/qxl_dev.h>
> +
> +#define __STDC_FORMAT_MACROS
> +#define __USE_MINGW_ANSI_STDIO 1
> +
> +#ifdef _MSC_VER // compiling with Visual Studio
> +#define PRIuPTR "Iu"
> +#else // compiling with mingw
> +#include <inttypes.h>
> +#endif // compiler specific definitions
> +
> #include "desktop_layout.h"
> #include "display_configuration.h"
> #include "vdlog.h"
> @@ -147,7 +157,7 @@ void DesktopLayout::set_displays()
> break;
> }
> if (display_id >= _displays.size()) {
> - vd_printf("display_id %lu out of range, #displays %zu" ,
> display_id, _displays.size());
> + vd_printf("display_id %lu out of range, #displays %" PRIuPTR ,
> display_id, _displays.size());
> break;
> }
> DisplayMode * mode(_displays.at(display_id));
Another smaller solution would be to use %lu and case to unsigned long,
I hardly think we can have a bigger array that need the size to be >32 bit.
Frediano
More information about the Spice-devel
mailing list