may have found a wrong warning?

Georg Steffers georg@steffers.org
Sat Jan 21 11:54:00 GMT 2006


Hi,

i just played around a little with wchar_t. I am not sure, but i think  
i got a warning that did not make any sense at all. Here's the small  
test:

#include <stdio.h>
#include <wchar.h>
#include <locale.h>

int
main (void)
{
    wchar_t a = L'©';      /* The copyright sign */

    setlocale (LC_ALL, "");
    printf ("char was %lc\n", a);

    return 0;
}

if i compile this with my gcc (GCC) 3.3.4 (pre 3.3.5 20040809) i got  
the following warning:

warning: character constant too long for its type

well, my linux uses UTF-8 and i know that the copyright sign is a 2byte  
multibyte. But if i use it with a wchar_t and the L modifier, i thought  
the compiler would change this multibyte to a correct 32bit unicode  
value? Well, at least the program works as expected. It prints the  
copyright sign.

Best regards
    Georg Steffers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20060121/1380f7a0/attachment.sig>


More information about the Gcc mailing list