From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30772 invoked by alias); 13 Aug 2012 09:34:50 -0000 Received: (qmail 30621 invoked by uid 22791); 13 Aug 2012 09:34:48 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_NUMERIC_HELO,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Aug 2012 09:34:35 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1T0r2U-0005x1-WA for gcc-help@gcc.gnu.org; Mon, 13 Aug 2012 11:34:23 +0200 Received: from 79.161.10.130 ([79.161.10.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 13 Aug 2012 11:34:22 +0200 Received: from david by 79.161.10.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 13 Aug 2012 11:34:22 +0200 To: gcc-help@gcc.gnu.org From: David Brown Subject: Re: 16-bit int Date: Mon, 13 Aug 2012 14:42:00 -0000 Message-ID: References: <5024C255.7030504@westcontrol.com> <5024CA1B.60903@westcontrol.com> <20120811104726.GI25354@xvii.vinc17.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: <20120811104726.GI25354@xvii.vinc17.org> X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2012-08/txt/msg00089.txt.bz2 On 11/08/2012 12:47, Vincent Lefevre wrote: > On 2012-08-10 09:05:13 +0000, Göran Steen wrote: >> Any C99 compiler - and almost all pre-C99 compilers - will have >> . I don't know of any compiler less than 15 years old that >> doesn't come with a , and many people using such compilers >> have written their own . > > I thought that Microsoft's compiler didn't have . > I've also heard that is more common. > >> The int_fast16_t and int_fast32_t types (and the unsigned versions) >> are mandatory in , so you can take it for granted that >> /all/ compilers support them. This is unlike the fixed-size types >> (like int16_t) that will be defined if and only if the target >> supports types of exactly that size (some architectures don't >> support the smaller types). > > But int_fast16_t is useless to test whether code can be affected > by 16-bit truncation on platforms for which int_fast16_t is really > a 16-bit type. For tests, int16_t is necessary. Now the user may > want to know what targets provide this type. > The use of "int_fast16_t" was to get correct and optimal code, whether the target is 16-bit or 32-bit. You are right that this will not test whether the code will work on 16-bit targets if it is compiled on a 32-bit target - using int16_t will help more for that (but it won't give guarantees, unless you are absolutely sure there are no hidden int promotions).