[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio

From: Christian Grothoff
Subject: Re: [libmicrohttpd] 0.9.62 doesn't build on Visual Studio
Date: Wed, 12 Dec 2018 01:08:35 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1

On 12/11/18 11:10 PM, Jonathan McDougall wrote:
> Line 1324, nonce in MHD_queue_auth_fail_response2().

Ack, will fix.

> 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__
>         TYPE NAME[(MAX_SIZE)]; \
>         if ((REAL_SIZE) > (MAX_SIZE)) \
>             mhd_panic(mhd_panic_cls, __FILE__, __LINE__, "VLA too big");
> #else
>         TYPE NAME[(REAL_SIZE)];
> #endif
> Use it like this:
> MAKE_VLA(uint8_t, dig, da->digest_size, MAX_DIGEST);

This won't work. Sometimes we have two VLA variables, and with this you
violate the c89 constraint that variables must be declared at the
beginning of a code block (and the 'if' statement is now in the middle
of the list of variable declarations).

> 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 don't see why not. Anyway, I was specifically avoiding your
construction style because of the c89 issue with not mixing statements
and variable declarations.  Did you try mine with VS, or is your
statement about this not being a 'constant' based on being picky about
reading the standard? Because with my macro, the compiler _could_
certainly figure out that there is only one possible length of this
array and generate the 'efficient' non-VLA logic.

> I would again urge you to reconsider going the VLA route and change this
> all back to constant sizes for all compilers.

Oh, but the 'old' version was only supporting one hash function, the new
one is hash function agnostic, and different hash functions have
different sizes. So we would suddenly drastically increase stack
requirements for MD5.

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]