From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,974799d066e5d38e X-Google-Attributes: gid103376,public From: Keith Thompson Subject: Re: Wide_Character vs. Interfaces.C.wchar_t Date: 1999/10/14 Message-ID: #1/1 X-Deja-AN: 536562577 Sender: kst@king.cts.com References: <87emez6nn6.fsf@deneb.cygnus.argh.org> X-Trace: thoth.cts.com 939886066 99647 198.68.168.21 (14 Oct 1999 07:27:46 GMT) Organization: CTS Network Services Newsgroups: comp.lang.ada X-Complaints-To: newsmaster@cts.com Date: 1999-10-14T00:00:00+00:00 List-Id: Florian Weimer writes: > ARM B.3 seems to imply the existance of a bijective mapping between > Wide_Character and Interfaces.C.wchar_t. ARM 3.5.2(3) requires that > Wide_Character has exactly 2**16 distinct values. What shall be done > if wchar_t (the C version) has more than just 16 significant bits? I don't think the mapping has to be bijective (assuming my memory of what that word means is correct ... consulting reference library ... not in dictionary ... trying CRC Math Tables ... yeah, that's what I thought). If wchar_t is 32 bits, presumably To_Ada would throw away the top 16 bits, and To_C would set them to 0. (Or one could argue that To_Ada should raise Constraint_Error if the argument won't fit in 16 bits.) The same situation occurs for Character and Interfaces.C.char; the only requirement imposed by the C standard is that char must have a range of at least -127..+127 or 0..255 (it can be either signed or unsigned). As it happens, almost all existing C compilers use 8 bits for char, so this doesn't tend to arise in real life. BTW, there is (at least) one problem with Interfaces.C: the declaration of wide_nul is wide_nul : constant wchar_t := wchar_t'First; which is clearly wrong if wchar_t is signed, as it is on at least some systems. I think there's an AI for this. -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> "Oh my gosh! You are SO ahead of your time!" -- anon.