From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailfilter05.hatteland.com (mailfilter05.hatteland.com [213.162.250.24]) by sourceware.org (Postfix) with ESMTPS id 527FD384A026 for ; Mon, 4 Jan 2021 09:41:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 527FD384A026 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=westcontrol.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=david@westcontrol.com X-Virus-Scanned: by SpamTitan at hatteland.com Authentication-Results: mailfilter05.hatteland.com; x-trusted-ip=pass X-Virus-Scanned: by SpamTitan at hatteland.com Authentication-Results: mailrelay01.hatteland.com; none Subject: Re: Question: C Standad/GCC Extension for How To Assign Binary Number to Unsigned To: jlmales@gmail.com, gcc-help@gcc.gnu.org Newsgroups: gmane.comp.gcc.help References: <20210103215931.60543737c7a1c825aafbe12a@gmail.com> From: David Brown Message-ID: Date: Mon, 4 Jan 2021 10:41:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20210103215931.60543737c7a1c825aafbe12a@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jan 2021 09:41:29 -0000 On 03/01/2021 22:59, John L. Males via Gcc-help wrote: > Hello, > > My question is not a need for programming assistance. My > question is to understand what the standard is for C with > respect to my questions. I have discovered a possible issue, > but want to ask questions first of expected C standard with > regards to my questions and if there are any related GCC > extensions to the questions. > I don't really think this is the best place to ask about C standards, but I'll try to give you some pointers. If you think there are issues about gcc's standards compliance, then of course this is a good starting point for discussing them. For details about the C (and C++) standards, I recommend this site: It covers just about everything that the standards themselves cover, but is a good deal easier to navigate and read. >From this you can see: Binary literals (such as 0b01001011) are planned for the future C23 standard, but are not included in any current C standard. (From the matching C++ page you can see they were standardised in C++14, along with optional separators such as 0b0100'1011.) For details about gcc, the gcc manual is available online for a range of versions: There are also many options in gcc for picking different standards - both "real" C standards and gcc extended "standards": > For the purposes of the questions the variable is an uint32_t. > > 1) What is the way to assign a bit value to variable? There are /many/ ways to do this - this is a basic C question, not a gcc question. > > 2) What is the format specifier to print a bit value with? printf format specifiers are part of the C standard: Different implementations of printf can have extensions with other format specifiers, but that is up to the implementation of the library, not the compiler. gcc is a compiler, not a complete toolchain - it has no printf. So if you are using a library on a POSIX system, you'll have the POSIX extensions to printf documented here: Maybe there will be more - it depends on the library. But I don't know of any printf implementation that supports printing binary numbers directly. > > 3) What will (2) print like? > > To be clear these questions are not abut programming > assistance, but what is the C standard and/or GCC extension. > > (Why did you include piles of data about your system? Did you think the C standards depend on the temperature of your cpu?) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id 06F6B384A026 for ; Mon, 4 Jan 2021 09:41:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 06F6B384A026 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=westcontrol.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gcc-help@m.gmane-mx.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1kwMMh-000AA0-JP for gcc-help@gcc.gnu.org; Mon, 04 Jan 2021 10:41:27 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-help@gcc.gnu.org From: David Brown Subject: Re: Question: C Standad/GCC Extension for How To Assign Binary Number to Unsigned Date: Mon, 4 Jan 2021 10:41:22 +0100 Message-ID: References: <20210103215931.60543737c7a1c825aafbe12a@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 In-Reply-To: <20210103215931.60543737c7a1c825aafbe12a@gmail.com> Content-Language: en-GB X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jan 2021 09:41:31 -0000 Message-ID: <20210104094122.h0Wl_3Qq0HLnL7GLatOvWJr_4MBQfWASSe0Iiuq3xgA@z> On 03/01/2021 22:59, John L. Males via Gcc-help wrote: > Hello, > > My question is not a need for programming assistance. My > question is to understand what the standard is for C with > respect to my questions. I have discovered a possible issue, > but want to ask questions first of expected C standard with > regards to my questions and if there are any related GCC > extensions to the questions. > I don't really think this is the best place to ask about C standards, but I'll try to give you some pointers. If you think there are issues about gcc's standards compliance, then of course this is a good starting point for discussing them. For details about the C (and C++) standards, I recommend this site: It covers just about everything that the standards themselves cover, but is a good deal easier to navigate and read. >From this you can see: Binary literals (such as 0b01001011) are planned for the future C23 standard, but are not included in any current C standard. (From the matching C++ page you can see they were standardised in C++14, along with optional separators such as 0b0100'1011.) For details about gcc, the gcc manual is available online for a range of versions: There are also many options in gcc for picking different standards - both "real" C standards and gcc extended "standards": > For the purposes of the questions the variable is an uint32_t. > > 1) What is the way to assign a bit value to variable? There are /many/ ways to do this - this is a basic C question, not a gcc question. > > 2) What is the format specifier to print a bit value with? printf format specifiers are part of the C standard: Different implementations of printf can have extensions with other format specifiers, but that is up to the implementation of the library, not the compiler. gcc is a compiler, not a complete toolchain - it has no printf. So if you are using a library on a POSIX system, you'll have the POSIX extensions to printf documented here: Maybe there will be more - it depends on the library. But I don't know of any printf implementation that supports printing binary numbers directly. > > 3) What will (2) print like? > > To be clear these questions are not abut programming > assistance, but what is the C standard and/or GCC extension. > > (Why did you include piles of data about your system? Did you think the C standards depend on the temperature of your cpu?)