What does the prefix L "..." mean in GCC C without #including wchar?

This is why it works unsigned short var= L'ÿ', but unsigned short var[]= L"ÿ";does not work?

+1
source share
5 answers

L'ÿ'has a type wchar_tthat can be implicitly converted to unsigned short. L"ÿ"has a type wchar_t[2]that cannot be implicitly converted to unsigned short[2].

+11
source

Lis a prefix for wide literals and wide format string literals. This is part of the language, not the headline. It is also not specific to GCC. They will be used like this:

wchar_t some_wchar = L'ÿ';
wchar_t *some_wstring = L"ÿ"; // or wchar_t some_wstring[] = L"ÿ";

unsigned short something = L'ÿ';, wchar_t . , wchar_t * short.

+4

wchar_t - typedef . , , . , , L'ß ' , , , , .

, . ( ) , , wchar_t. , void*.

+2

, , , , . Windows wchar_t 16- Unicode, 16- . , ( C BMP Unicode , C), .

Unix- 32- wchar_t, , , , short * wchar_t * .

+1

C

  • 'Y' - char, int , , L,
  • "y" is a string constant, and you cannot translate it to an integer value
0
source

Source: https://habr.com/ru/post/1652746/


All Articles