MSVC: VS2013 comes with inttypes.h
PATCH 2/2 MSVC: VS2013 comes with inttypes.h
Reduce the number of defines which need to be managed within vanilal git.
--- compat/mingw.h | 2 +- compat/vcbuild/include/unistd.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
compat/mingw.h +1 -1
@@ -415,7 +415,7 @@ int mingw_offset_1st_component(const char *path);extern void build_libgit_environment (void );extern const char *program_data_config (void );#define git_program_data_config program_data_config -#ifndef __MINGW64_VERSION_MAJOR +#if !defined(__MINGW64_VERSION_MAJOR) || !defined(_MSC_VER) || _MSC_VER <1800 #define PRIuMAX "I64u"#define PRId64 "I64d"#else
compat/vcbuild/include/unistd.h +2 -0
@@ -45,11 +45,13 @@ typedef unsigned long long uintmax_t;typedef int64_t off64_t ; +#if !defined(_MSC_VER) || _MSC_VER <1800 #define INTMAX_MIN _I64_MIN#define INTMAX_MAX _I64_MAX#define UINTMAX_MAX _UI64_MAX#define UINT32_MAX 0xffffffff/* 4294967295U */ +#endif #define STDIN_FILENO 0#define STDOUT_FILENO 1
Signature · 1 line
2.7.4.windows.1
--- compat/mingw.h | 2 +- compat/vcbuild/include/unistd.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
compat/mingw.h +1 -1
@@ -415,7 +415,7 @@ int mingw_offset_1st_component(const char *path);extern void build_libgit_environment (void );extern const char *program_data_config (void );#define git_program_data_config program_data_config -#ifndef __MINGW64_VERSION_MAJOR +#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER <1800 )#define PRIuMAX "I64u"#define PRId64 "I64d"#else
compat/vcbuild/include/unistd.h +4 -0
@@ -45,11 +45,15 @@ typedef unsigned long long uintmax_t;typedef int64_t off64_t ; +#if !defined(_MSC_VER) || _MSC_VER <1800 #define INTMAX_MIN _I64_MIN#define INTMAX_MAX _I64_MAX#define UINTMAX_MAX _UI64_MAX#define UINT32_MAX 0xffffffff/* 4294967295U */ +#else +#include <inttypes.h> +#endif #define STDIN_FILENO 0#define STDOUT_FILENO 1
Signature · 1 line
2.7.4.windows.1
Quoted 2 lines · Sven Strickroth
Signed-off-by Sven Strickroth <[email protected]>---
Ah, I didn't finish the comment I started to write here for the first round. My "Hmph" was meant to be followed by something like "Compared to 1/2 which clearly described what got changed, this does not say much to summarize what it did to help readers".
Re-reading the patch text, I tend to agree with you that the title "comes with inttypes.h" may be sufficient for readers to reason about the change, and it would not be necessary to explain that we can lose fallback definitions by including it.
Quoted 23 lines
compat/mingw.h | 2 +- compat/vcbuild/include/unistd.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)compat/mingw.h +1
-1@@ -415,7 +415,7 @@ int mingw_offset_1st_component(const char *path);extern void build_libgit_environment (void );extern const char *program_data_config (void );#define git_program_data_config program_data_config -#ifndef __MINGW64_VERSION_MAJOR +#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER <1800 )#define PRIuMAX "I64u"#define PRId64 "I64d"#else compat/vcbuild/include/unistd.h +0
-0@@ -45,11 +45,15 @@ typedef unsigned long long uintmax_t;
compat/vcbuild/include/unistd.h typedef unsigned long long uintmax_t; · line 55
Quoted 10 lines
compat/vcbuild/include/unistd.h +3
-0typedef int64_t off64_t ; +#if !defined(_MSC_VER) || _MSC_VER <1800 #define INTMAX_MIN _I64_MIN#define INTMAX_MAX _I64_MAX#define UINTMAX_MAX _UI64_MAX#define UINT32_MAX 0xffffffff/* 4294967295U */ +#else +#include <inttypes.h>
Somebody lost a SP here, it seems.
Quoted 4 lines
compat/vcbuild/include/unistd.h +1
-0+#endif #define STDIN_FILENO 0#define STDOUT_FILENO 1
compat/mingw.h int mingw_offset_1st_component(const char *path); · line 421
Quoted 11 lines · Sven Strickroth
compat/mingw.h +1
-1@@ -415,7 +415,7 @@ int mingw_offset_1st_component(const char *path);extern void build_libgit_environment (void );extern const char *program_data_config (void );#define git_program_data_config program_data_config -#ifndef __MINGW64_VERSION_MAJOR +#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER <1800 )#define PRIuMAX "I64u"#define PRId64 "I64d"#else
ACK for this part. For reference see [1].
Quoted 7 lines
compat/vcbuild/include/unistd.h +0
-0@@ -45,11 +45,15 @@ typedef unsigned long long uintmax_t;typedef int64_t off64_t ;
compat/vcbuild/include/unistd.h typedef unsigned long long uintmax_t; · line 56
Quoted 10 lines
compat/vcbuild/include/unistd.h +4
-0+#if !defined(_MSC_VER) || _MSC_VER <1800 #define INTMAX_MIN _I64_MIN#define INTMAX_MAX _I64_MAX#define UINTMAX_MAX _UI64_MAX#define UINT32_MAX 0xffffffff/* 4294967295U */ +#else +#include <inttypes.h> +#endif
If we would do "#include <stdint.h>" here instead, we could lower the _MSC_VER requirement to at least 1700. According to the comment at [2] we could lower it even to 1600.
Also the original code is missing a single space after "#include".
[1] https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/
[2] https://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio#comment4620359_126279
Regards,
Sebastian
Re: [PATCH 2/2 V3] MSVC: Use shipped headers instead of fallback definitions
VS2010 comes with stdint.h [1]
VS2013 comes with inttypes.h [2]
[1] https://stackoverflow.com/a/2628014/3906760
[2] https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/
--- compat/mingw.h | 2 +- compat/vcbuild/include/unistd.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
compat/mingw.h +1 -1
@@ -415,7 +415,7 @@ int mingw_offset_1st_component(const char *path);extern void build_libgit_environment (void );extern const char *program_data_config (void );#define git_program_data_config program_data_config -#ifndef __MINGW64_VERSION_MAJOR +#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER <1800 )#define PRIuMAX "I64u"#define PRId64 "I64d"#else
compat/vcbuild/include/unistd.h +4 -0
@@ -45,11 +45,15 @@ typedef unsigned long long uintmax_t;typedef int64_t off64_t ; +#if !defined(_MSC_VER) || _MSC_VER <1600 #define INTMAX_MIN _I64_MIN#define INTMAX_MAX _I64_MAX#define UINTMAX_MAX _UI64_MAX#define UINT32_MAX 0xffffffff/* 4294967295U */ +#else +#include <stdint.h> +#endif #define STDIN_FILENO 0#define STDOUT_FILENO 1
Signature · 1 line
2.7.4.windows.1
Re: [PATCH 2/2 V3] MSVC: Use shipped headers instead of fallback definitions
Quoted 7 lines · Sven Strickroth
VS2010 comes with
stdint.h[1]
VS2013 comes withinttypes.h[2][1] https://stackoverflow.com/a/2628014/3906760
[2] https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/Signed-off-by Sven Strickroth <[email protected]>
ACK.
Regards,
Sebastian
Re: [PATCH 2/2 V3] MSVC: Use shipped headers instead of fallback definitions
In reply to Sven StrickrothHi Sven,
Quoted 7 lines · Sven Strickroth
VS2010 comes with
stdint.h[1]
VS2013 comes withinttypes.h[2][1] https://stackoverflow.com/a/2628014/3906760
[2] https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/Signed-off-by Sven Strickroth <[email protected]>
Much, much, much better commit message (even if there is still room for a more pleasant read).
ACK
Dscho
Re: [PATCH 2/2 V3] MSVC: Use shipped headers instead of fallback definitions
In reply to Sven Strickrothcompat/mingw.h int mingw_offset_1st_component(const char *path); · line 421
Quoted 13 lines · Sven Strickroth
compat/mingw.h +1
-1@@ -415,7 +415,7 @@ int mingw_offset_1st_component(const char *path);extern void build_libgit_environment (void );extern const char *program_data_config (void );#define git_program_data_config program_data_config -#ifndef __MINGW64_VERSION_MAJOR +#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER <1800 )#define PRIuMAX "I64u"#define PRId64 "I64d"#else
I'll wiggle this in, but you seem to be building on top of some unrelated work (please avoid sending such a patch in the future).
Thanks, all of you.
-- >8 --
From: Sven Strickroth <[email protected]>
Date: Wed, 30 Mar 2016 13:37:36 +0200
Subject: [PATCH] MSVC: use shipped headers instead of fallback definitions
VS2010 comes with stdint.h [1]
VS2013 comes with inttypes.h [2]
[1] https://stackoverflow.com/a/2628014/3906760
[2] https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/
--- compat/mingw.h | 2 +- compat/vcbuild/include/unistd.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
compat/mingw.h +1 -1
@@ -406,7 +406,7 @@ static inline void convert_slashes(char *path)int mingw_offset_1st_component (const char *path);#define offset_1st_component mingw_offset_1st_component#define PATH_SEP ';' -#ifndef __MINGW64_VERSION_MAJOR +#if !defined(__MINGW64_VERSION_MAJOR) && (!defined(_MSC_VER) || _MSC_VER <1800 )#define PRIuMAX "I64u"#define PRId64 "I64d"#else
compat/vcbuild/include/unistd.h +4 -0
@@ -45,11 +45,15 @@ typedef unsigned long long uintmax_t;typedef int64_t off64_t ; +#if !defined(_MSC_VER) || _MSC_VER <1600 #define INTMAX_MIN _I64_MIN#define INTMAX_MAX _I64_MAX#define UINTMAX_MAX _UI64_MAX#define UINT32_MAX 0xffffffff/* 4294967295U */ +#else +#include <stdint.h> +#endif #define STDIN_FILENO 0#define STDOUT_FILENO 1
Signature · 1 line
2.8.0-215-gd29a7d9
Quoted 1 line · Sven Strickroth
Reduce the number of defines which need to be managed within vanilal git.
Hmph.
Quoted 3 lines
Signed-off-by Sven Strickroth <[email protected]>---
I am not qualified to judge the correctness of the assertions this change makes:
* MSVC at or newer than version 1800 have PRIuMAX and PRId64
* MSVC at or newer than version 1800 have {UINT,INT}MAX_{MIN,MAX}
and will wait for Windows folks to Ack.
Thanks.
Quoted 35 lines
compat/mingw.h | 2 +- compat/vcbuild/include/unistd.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)compat/mingw.h +1
-1@@ -415,7 +415,7 @@ int mingw_offset_1st_component(const char *path);extern void build_libgit_environment (void );extern const char *program_data_config (void );#define git_program_data_config program_data_config -#ifndef __MINGW64_VERSION_MAJOR +#if !defined(__MINGW64_VERSION_MAJOR) || !defined(_MSC_VER) || _MSC_VER <1800 #define PRIuMAX "I64u"#define PRId64 "I64d"#else compat/vcbuild/include/unistd.h +2
-0@@ -45,11 +45,13 @@ typedef unsigned long long uintmax_t;typedef int64_t off64_t ; +#if !defined(_MSC_VER) || _MSC_VER <1800 #define INTMAX_MIN _I64_MIN#define INTMAX_MAX _I64_MAX#define UINTMAX_MAX _UI64_MAX#define UINT32_MAX 0xffffffff/* 4294967295U */ +#endif #define STDIN_FILENO 0#define STDOUT_FILENO 1