[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio
From: |
Jonathan McDougall |
Subject: |
Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio |
Date: |
Tue, 11 Dec 2018 17:10:19 -0500 |
On 12/11/18, Christian Grothoff <address@hidden> wrote:
> e13c79ee..273a6df9 #ifdef's the VLA logic as discussed, but would be
> nice if someone with VS could confirm that the compiler is now happy,
> especially as my VLA_ARRAY_LEN_DIGEST macro generates stuff like
>
> char array[((n<4)?1:abort()),4];
>
> which I'm not 100% sure will be read as an obviously constant-size
> array by some compilers ;-).
It wouldn't be a constant expression for any compiler, the C standard
says it's not. You're calling a function and using a global variable and
a local variable in there. The fact that the _result_ of the expression
is a constant expression doesn't make the whole expression constant.
> Also, I might have overlooked a VLA somewhere...
Line 1324, nonce in MHD_queue_auth_fail_response2().
Since you're willing to use C99 features, here's what I'm thinking. In
w32/common/MHD_config.h, you want an exception for the clang toolset,
which does support VLAs:
/* MS VC doesn't support VLAs, but the clang toolset does */
#ifndef __clang__
#define __STDC_NO_VLA__ 1
#endif
and change your macro to something like this:
#if __STDC_NO_VLA__
#define MAKE_VLA(TYPE, NAME, REAL_SIZE, MAX_SIZE) \
TYPE NAME[(MAX_SIZE)]; \
if ((REAL_SIZE) > (MAX_SIZE)) \
mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big");
#else
#define MAKE_VLA(TYPE, NAME, REAL_SIZE, MAX_SIZE) \
TYPE NAME[(REAL_SIZE)];
#endif
Use it like this:
MAKE_VLA(uint8_t, dig, da->digest_size, MAX_DIGEST);
There are a few definitions that have a complicated size, with a
combination of the digest size and NONCE_STD_LEN, I'd pay special
attention to those, they might not work with my macro.
I would again urge you to reconsider going the VLA route and change this
all back to constant sizes for all compilers.
--
Jonathan McDougall
- [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Jonathan McDougall, 2018/12/09
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Tim Rühsen, 2018/12/10
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Christian Grothoff, 2018/12/10
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Tim Rühsen, 2018/12/10
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Jonathan McDougall, 2018/12/10
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Christian Grothoff, 2018/12/10
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Christian Grothoff, 2018/12/11
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio,
Jonathan McDougall <=
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Christian Grothoff, 2018/12/11
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Jonathan McDougall, 2018/12/11
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Christian Grothoff, 2018/12/12
- Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio, Jonathan McDougall, 2018/12/12