Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more
- From
Sebastian Schuberth <sschuberth@gmail.com>
- Date
- Mar 29, 2016, 19:20 UTC
- Message-ID
- <CAHGBnuNkuiyk1uvJqT1_1UWOhpVTg+TxJ2QvepuMBpvOD8AyFw@mail.gmail.com>
- In-Reply-To
- <56FAD3DD.4060009@cs-ware.de>
On Tue, Mar 29, 2016 at 9:13 PM, Sven Strickroth <sven@cs-ware.de> wrote:
Show 13 quoted lines
> diff --git a/compat/snprintf.c b/compat/snprintf.c > index 42ea1ac..0b11688 100644 > --- a/compat/snprintf.c > +++ b/compat/snprintf.c > @@ -9,7 +9,7 @@ > * always have room for a trailing NUL byte. > */ > #ifndef SNPRINTF_SIZE_CORR > -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) > +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900) > #define SNPRINTF_SIZE_CORR 1 > #else > #define SNPRINTF_SIZE_CORR 0
I wonder if the logic is (and was) sensible here. We assume that every non-__GNUC__ and non-_MSC_VER compiler on Windows requires the correction. Wouldn't it make sense to not assume requiring the correction unless we know the compiler has this bug? That is, shouldn't this better say
#if defined(WIN32) && (defined(__GNUC__) && __GNUC__ < 4) || (defined(_MSC_VER) && _MSC_VER < 1900)) #define SNPRINTF_SIZE_CORR 1 #else #define SNPRINTF_SIZE_CORR 0
-- Sebastian Schuberth