WININET: make WCHAR strings const where possible

Francois Gouget fgouget at
Sat Apr 17 16:11:57 CDT 2004

On Tue, 13 Apr 2004, Shachar Shemesh wrote:
> >are declared both static and const. Is the static necessary in that
> >context?
> >
> The static is even more necessary in that context. Outside of functions,
> all static does is limit the scope. Inside functions, static prevents
> the var from taking stack space.

I wrote a teeny test app to check this out and you're right. The static
is crucial. If it's not specified the string is copied to the stack so
that the const essentially has no effect whatsoever (no compiler warning
and no runtime error). With 'static const' we still don't get a compiler
warning (tested with gcc version 3.3.3 (Debian 20040321)) but we get a
runtime crash, i.e. the string is really const this time.

#include <stdio.h>

void foo()
    /*static*/ /*const*/ char buf[]={'a',':','b',':','c',':','d',0};
    char* c;

    if (c)
        *c=' ';

int main()
    return 0;

Francois Gouget         fgouget at
                     Linux: the choice of a GNU generation

More information about the wine-devel mailing list