Hi,

On Thu, Aug 25, 2022 at 10:36:21PM +0200, Gert Doering wrote:
> On Wed, Aug 24, 2022 at 06:57:18PM +0200, Arne Schwabe wrote:
> >   Error: test_provider.c(74): error C2099: initializer is not a constant
> > 
> > Fix this issue by making the const char* to const char[]. This is probably
> > of one the weird array decay corner cases
> 
> Out of curiosity - does the error go away if you just remove all these
> "const" from the declaration?  Making this just a "static char *"?

Ah, I see the problem.  Unrelated to those "consts", but technically,

char * a = "foo"

is a pointer variable initialized with the memory location of "foo",
while

char b[] = "foo"

is an array.  *Usage* in C is synonymous, because "a" will get the
address stored in the pointer variable, while "b" will just give us
the memory location, both being "the memory location where "foo" is
stored".

Usage in a compile time initialization is indeed different, as

char *c[] = { a, b };

would strictly speaking need to load the value of "a" here...  which
should work at runtime, inside a function, but seemingly not with all
compilers at compile time for a static global.

Interesting :-)

gert
-- 
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to