From owner-freebsd-questions@freebsd.org Wed Jun 16 02:54:20 2021 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 42458659167 for ; Wed, 16 Jun 2021 02:54:20 +0000 (UTC) (envelope-from kh@panix.com) Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4G4VBy6gdRz4WWJ for ; Wed, 16 Jun 2021 02:54:18 +0000 (UTC) (envelope-from kh@panix.com) Received: from rain.home (pool-96-230-243-2.bstnma.fios.verizon.net [96.230.243.2]) by mailbackend.panix.com (Postfix) with ESMTPSA id 4G4VBy2mGcz497Z for ; Tue, 15 Jun 2021 22:54:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=panix.com; s=panix; t=1623812058; bh=lAapByGGKrXEKHAOvw6+bk4Qdur9QEc4pHmOoDz1BS4=; h=Subject:To:References:From:Date:In-Reply-To; b=FJY8X6vxvdMLEv4JOlw0ZvlfV/A3BprFQKF3ufXUgnZWYJUfcp0Y4I3Q65X5ZtVjC AlEblMjUC8bu10McmCpiPseGeV4f4S0SCs9waj7Dxb4Zn9jEtXI0v27M3SUE8ZLdPT SaxDHY802ON96dXjVjbDOwEh/chJvNg7Nuzg9w8I= Subject: Re: Why doesn't cc -ansi disable conflicting type for getline from stdio.h? To: freebsd-questions@freebsd.org References: From: Kurt Hackenberg Message-ID: <4018acc9-2607-67ed-0327-8a3c9bc647b8@panix.com> Date: Tue, 15 Jun 2021 22:54:14 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4G4VBy6gdRz4WWJ X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=panix.com header.s=panix header.b=FJY8X6vx; dmarc=none; spf=pass (mx1.freebsd.org: domain of kh@panix.com designates 166.84.1.89 as permitted sender) smtp.mailfrom=kh@panix.com X-Spamd-Result: default: False [-4.20 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[166.84.1.89:from]; R_SPF_ALLOW(-0.20)[+ip4:166.84.0.0/16:c]; TO_DN_NONE(0.00)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; DKIM_TRACE(0.00)[panix.com:+]; RCVD_IN_DNSWL_MED(-0.20)[166.84.1.89:from]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; SUBJECT_ENDS_QUESTION(1.00)[]; ASN(0.00)[asn:2033, ipnet:166.84.0.0/16, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[96.230.243.2:received]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[panix.com:s=panix]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[panix.com]; RCPT_COUNT_ONE(0.00)[1]; DWL_DNSWL_LOW(-1.00)[panix.com:dkim]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-questions] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2021 02:54:20 -0000 On 2021/06/14 17:10, Edward Sanford Sutton, III wrote: > Trying to work on properly learning C so following K&R second edition > of C Programming Language. Found in manpage that -std=c89 or -ansi can > be passed to setup a more compatible set of build rules which hid > warnings about how main is defined. > My understanding is that this should also cause getline to not be > defined in /usr/include/stdio.h. Is there a reason that "#if > __POSIX_VISIBLE >= 200809" should trigger as true in there with > -std=c89? Huh. I didn't know about that function getline() as part of the C library. The latest C reference I have is for C99, 1999; it doesn't include getline(). You may have run across dueling standards or something. Posix defines a standard Unix, and apparently also defines a C standard library that's a little larger than the C standard library defined by the C standard, even though Posix doesn't define C. (Yes, that's a little weird.) The boundary between C and Unix has always been blurred a little in practice. It's good to keep the boundary clear in your mind, but you might have to accept some imperfection in software. I suggest you take that getline() thing as a glitch, the kind of thing that shows up in old software[1], and work around it without worrying about it too much. Definitely rename the function in the sample program. As for learning C, K & R is the classic for that, but it's 30 years old. I suggest that you go through that, and when you more or less have a handle on the language, also look at more modern versions of C. There were significant changes in 1999 and 2011 -- not fundamental changes, but some useful additions. [1] C and Unix are 50 years old! That's pretty damn old for software.