[Spice-devel,vdagent-win,V3,07/11] Fix building with Visual Studio (inttypes.h)

Submitted by Uri Lublin on Dec. 30, 2014, 4:20 p.m.

Details

Message ID 88b9b74d95fdb1fb680742e586c1a29ed127da52.1419954144.git.uril@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Uri Lublin Dec. 30, 2014, 4:20 p.m.
As a followup of commit 462295d9f84658aa7.

Building with Visual Studio, fails as there is no inttypes.h file:
  vdagent\file_xfer.cpp(21) : fatal error C1083: Cannot open
  include file: 'inttypes.h': No such file or directory

This commit prevents including inttypes.h when building with Visual Studio,
and defines PRIu64 that is defined in inttypes.h for mingw compiler.
---
 vdagent/file_xfer.cpp |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

Patch hide | download patch | download mbox

diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
index f8cd07f..3aad4ac 100644
--- a/vdagent/file_xfer.cpp
+++ b/vdagent/file_xfer.cpp
@@ -18,7 +18,14 @@ 
 #include <shlobj.h>
 #define __STDC_FORMAT_MACROS
 #define __USE_MINGW_ANSI_STDIO 1
+
+// compiler specific definitions
+#ifdef _MSC_VER // compiling with Visual Studio
+#define PRIu64 "I64u"
+#else // compiling with mingw
 #include <inttypes.h>
+#endif // compiler specific definitions
+
 #include <stdio.h>
 #include "file_xfer.h"
 #include "as_user.h"

Comments

On Tue, Dec 30, 2014 at 5:20 PM, Uri Lublin <uril@redhat.com> wrote:
> As a followup of commit 462295d9f84658aa7.
>
> Building with Visual Studio, fails as there is no inttypes.h file:
>   vdagent\file_xfer.cpp(21) : fatal error C1083: Cannot open
>   include file: 'inttypes.h': No such file or directory
>
> This commit prevents including inttypes.h when building with Visual Studio,
> and defines PRIu64 that is defined in inttypes.h for mingw compiler.

Just a note here.
I don't know if someone builds virt-viewer with Visual Studio, but
this commit also would make sense there.

> ---
>  vdagent/file_xfer.cpp |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
> index f8cd07f..3aad4ac 100644
> --- a/vdagent/file_xfer.cpp
> +++ b/vdagent/file_xfer.cpp
> @@ -18,7 +18,14 @@
>  #include <shlobj.h>
>  #define __STDC_FORMAT_MACROS
>  #define __USE_MINGW_ANSI_STDIO 1
> +
> +// compiler specific definitions
> +#ifdef _MSC_VER // compiling with Visual Studio
> +#define PRIu64 "I64u"
> +#else // compiling with mingw
>  #include <inttypes.h>
> +#endif // compiler specific definitions
> +
>  #include <stdio.h>
>  #include "file_xfer.h"
>  #include "as_user.h"
> --
> 1.7.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


Best Regards,