Am 24.03.23 um 22:12 schrieb Selva Nair:
Hi,

On Fri, Mar 24, 2023 at 4:18 PM Matthias Andree
<matthias.and...@gmx.de> wrote:

    Am 23.03.23 um 15:31 schrieb Frank Lichtenheld:
    > Currently this is not obvious since we never build the
    > UTs with MSVC, but it doesn't like the initializers with
    > "const" variables. They cause
    > error C2099: initializer is not a constant

    What MSVC version are you using? What options? I've tried with a
    minimal
    C program with static const char *const foo = "something"; and it
    compiled with the latest 2017 or 2022 MSVC.


That will work but the following wont:

const char *const foo = "something";
const char *const bar = foo;

which is essentially the issue at hand. And more of the same with
struct initialization. As bar has static storage duration, it has to
be intialized by a "constant expression" which in C does not include
"const variables". Though it works with gcc.  In C99, automatic
variables can be intialized so, and the alternative I suggested uses
that approach.


I must have missed that bar = foo part, which is indeed nonconforming
code in C.

With Microsoft tools, I always wonder if it's not easier in practice to
make sure the same source code is also valid C++ and grind it in the C++
mixer^Wcompiler instead.
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to