Pergunta

Suppose that wc is a wchar_t and c is a char.
1) Is there any different between these two assignments?

c = 'a';
wc = L'a';

2) Is there any rule that force equality of c and wc for ASCII values? What does exactly mean wc == c to compiler?

Foi útil?

Solução

No -- the standard guarantees that both the basic execution character set and the basic wide execution character set will contain 'a', but does not guarantee that it will have the same value in both.

§2.3/3 gives a few restrictions (e.g., digits shall be consecutive), none of which applies here, and a final: "The values of the members of the execution character sets and the sets of additional members are locale-specific."

So, not only is it not guaranteed, but at least in theory it could even change when/if you change the locale.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top