[Spice-devel] [vdagent-win PATCH] fix format string for Visual Studio

Christophe Fergeau cfergeau at redhat.com
Mon Jul 24 15:51:59 UTC 2017


On Mon, Jul 24, 2017 at 11:44:25AM -0400, Frediano Ziglio wrote:
> > 
> > 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.

yup, probably easier.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170724/742ba435/attachment.sig>


More information about the Spice-devel mailing list