C++ Logo


Advanced search

Re: [std-proposals] Remove multicharacter literals

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 06 Mar 2024 13:35:31 -0800
On Wednesday, 6 March 2024 13:19:17 PST veronica alphonso via Std-Proposals
> 1. These are weird to handle because they basically depend on how many
> characters can an int encode, which is implementation-defined, so to use
> these well in a cross-platform environment you have to uh... constrast
> the number of characters with the size & alignment of an int
> Multi-character literals are unreliable to encode into an int because these
> depend on the implementation-defined size of int to know how many
> characters you can encode into, which in my opinion, is horrible.
> Also, multi-character literals are unnecessary, most codebases use wide,
> UTF-16 or UTF32 encodings to encode multi-character literals appropriately
> (yes, i know wchar_t is less than ideal, but lets ignore that for now).
> I don't think this feature serves any purpose nowadays, and the few
> codebases that may still use it should remove its support and get into the
> more reliable approaches, so this feature can be deprecated once and for
> all.

Add: if you want to write a string using them, you have to know whether the
machine is big-endian or not.

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmultichar"
    /* detect GenuineIntel */
    __cpuid(0, max_level, ebx, ecx, edx);
    if (ecx != 'letn' || edx != 'Ieni' || ebx != 'uneG') {

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Principal Engineer - Intel DCAI Cloud Engineering

Received on 2024-03-06 21:35:34