From owner-freebsd-questions@freebsd.org Mon Jun 14 21:10:34 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 2ADCC653B4A for ; Mon, 14 Jun 2021 21:10:34 +0000 (UTC) (envelope-from mirror176@hotmail.com) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2053.outbound.protection.outlook.com [40.92.42.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "DigiCert Cloud Services CA-1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G3kcn0NBsz3Cgg for ; Mon, 14 Jun 2021 21:10:32 +0000 (UTC) (envelope-from mirror176@hotmail.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=od3pLWRi+QjkFH7atI2DKAac3KgyVowVNoEEg5ugKs+xM4Yko5c7/yl9S2XPOInCa7TgX46BQhBKc47JkSDZ4QmLF3Sgpm+kfT68nEeYGB6w58EF7VHhznXKZ0D91sSs/iyNkxTQcQfh1omaKPRVbmstD2/M0IbgKD8fbeYOoUT1rIk9Zvd3jebHmPLfG7P5ij/VX0R5LN2UJIT4Vb1GMHRIOxaOSZDIYOWfG9EidTQu3rMesAlTCR/P+EcXuXNjVJgluXadWZ2FO0lvP/To/HgJP6rhILK57N/oNEqZmlv4uMeaxRmuH1whwkhhDtakWDH/+pP5ui9Va0HXGILVQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bP7oYiKZcNyVx+sTD6WpxCFNTXUme+J0QOWN2/o0uGM=; b=CwyCsZXPOVeqE6eVYthSbRRkD0etkr5Lc1GhVpHZxcel4lqiq/mOrHWV5EU/HHW+ZyY0yhe1VbOEKNefRIdgEQ3dQ99Ul3kkF8HSxAKKWlOZZ4aP7mgg5NU8PvmSjGA9h+w29fuSnhH+m+JMc9N5yBr72qi9/Sjbw0RlMBcQGDuW8qhI0h2w7i9ToytlPjfFVhmsH+07rP+bOHkPrycWmwsn32p5p/Wie/pZFCmQXXKa4IZJB/p+PSPJalvR/jUOHVXjeEZzmeDL8ILLYQGE4ZTkeG7ENJJpC41TB0XcJkcrNCqY3q8asT2OFYW1qwry0T0IliT48corbPjwFCl9kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bP7oYiKZcNyVx+sTD6WpxCFNTXUme+J0QOWN2/o0uGM=; b=SGQPKJbkF7d7d7czTqA0JWRn+uHNtGWWKCkPrffrwvYtzMtUsfCgEt9fpIA/Omvm9QmfJICrOFXKoq/E04EtfIkLLjkI7gHsUT0G7mjzGVo+WTqYpkGpWHVwWVweiLdP8C+oPoCJCopMIi1BXJZF+PQWb1yxpr8KJCb0SoEH9Gzf10lnwYqlHi32b1uGrqi8wMn4MowDgGw1V+m4xSVhTTa3ahs+wJQ2GF4IpGajQr9WlSYXD4bjbht1BflYJtKXsI2/l+rCqUlnAA/BfUBULNALx8t+uVzregJXDgU65hwpNbK/UPvskGtZLXBnTdLoyZVxjGmWVhfbxnpWSicuUQ== Received: from DM6NAM10FT033.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::50) by DM6NAM10HT129.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e86::219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.18; Mon, 14 Jun 2021 21:10:31 +0000 Received: from DM6PR03MB3674.namprd03.prod.outlook.com (2a01:111:e400:7e86::43) by DM6NAM10FT033.mail.protection.outlook.com (2a01:111:e400:7e86::148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.18 via Frontend Transport; Mon, 14 Jun 2021 21:10:31 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:839F364763A760D0D8ED94E9F4A466F0CC6EFBDDF02F896B8F5CDA22A9D6A6E7; UpperCasedChecksum:147D51C92142DA159F585B2C26B1CCCD9EE6882B13E59EB36F1391A79A4B63BC; SizeAsReceived:8541; Count:43 Received: from DM6PR03MB3674.namprd03.prod.outlook.com ([fe80::bcaf:331f:88da:3b9b]) by DM6PR03MB3674.namprd03.prod.outlook.com ([fe80::bcaf:331f:88da:3b9b%7]) with mapi id 15.20.4219.025; Mon, 14 Jun 2021 21:10:31 +0000 To: freebsd-questions@freebsd.org From: "Edward Sanford Sutton, III" Subject: Why doesn't cc -ansi disable conflicting type for getline from stdio.h? Message-ID: Date: Mon, 14 Jun 2021 14:10:28 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LGwTt1xj1LKnYCBVxoiegy1f8qZiYRC1p" X-TMN: [vTU0/1HatVBbHv7LJxZsN2LV/R5mAxUN] X-ClientProxiedBy: SJ0PR05CA0019.namprd05.prod.outlook.com (2603:10b6:a03:33b::24) To DM6PR03MB3674.namprd03.prod.outlook.com (2603:10b6:5:aa::16) X-Microsoft-Original-Message-ID: <9d793a27-659e-7b0a-ad9e-6eee34c2dc62@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from darkstar.l.net (70.162.106.2) by SJ0PR05CA0019.namprd05.prod.outlook.com (2603:10b6:a03:33b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.9 via Frontend Transport; Mon, 14 Jun 2021 21:10:30 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 43 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 8bc2f805-323d-4eaf-ac0c-08d92f78d786 X-MS-TrafficTypeDiagnostic: DM6NAM10HT129: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5X8zA4WSDbDrGhfPHfjwRcucbH2+vQSCmckNBQ/SYBmrvBCjDpBzAfg9PThVx/5vzls5CINsgjA7d8JqsoguSs3UR48LOzuOkjKAnuaQEObgkUJ9yFEiNM62AOra5r1ZqMwxgBjlMc7pyJB/dMPmC/YBmiNReE2xY0/kAsSEe3LzX2FIf4aY/qHnfxGvAzd0sXXFld5+FvtbabIGRDFzrX03HmhHcmiKvmuc2y+7K7UKAxzpQeNNGiJX1j0W47BaRUTDjppB4HLhvpNRoga9bZ92lwy1pleChIqvDcPrG5jZ5gUFE/qQAB2vZwh21Y/d/u4W9oYKU2QFhRzllIwxs3O6l/OZO5s7iB5ErBP5cAoDHLdVmkJNK/fHOQNRSN9QY77IxqDS0yCb7hbMCrbs4A== X-MS-Exchange-AntiSpam-MessageData: rouNtnpX1LlB3ZpwI4lSEm3mplQqu+31sJhUEWzIoApS5/g4oKIDrbsdM19sLKSheFVkPbnvgulXIFsJ9buXsRuh874u42MjhgTWc3pNuPnm7z8Bc3hGs9C8xWl2jRQ6kRqfo278lRE6+ApgMQ5KHQ== X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bc2f805-323d-4eaf-ac0c-08d92f78d786 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2021 21:10:31.1242 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DM6NAM10FT033.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6NAM10HT129 X-Rspamd-Queue-Id: 4G3kcn0NBsz3Cgg X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=hotmail.com header.s=selector1 header.b=SGQPKJbk; arc=pass (microsoft.com:s=arcselector9901:i=1); dmarc=pass (policy=none) header.from=hotmail.com; spf=pass (mx1.freebsd.org: domain of mirror176@hotmail.com designates 40.92.42.53 as permitted sender) smtp.mailfrom=mirror176@hotmail.com X-Spamd-Result: default: False [-3.60 / 15.00]; FREEMAIL_FROM(0.00)[hotmail.com]; R_SPF_ALLOW(-0.20)[+ip4:40.92.0.0/15]; HAS_ATTACHMENT(0.00)[]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[hotmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[hotmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; SUBJECT_ENDS_QUESTION(1.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:~]; FREEMAIL_ENVFROM(0.00)[hotmail.com]; FORGED_MUA_THUNDERBIRD_MSGID_UNKNOWN(2.50)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[40.92.42.53:from]; ASN(0.00)[asn:8075, ipnet:40.80.0.0/12, country:US]; DWL_DNSWL_NONE(0.00)[hotmail.com:dkim]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[hotmail.com:s=selector1]; RCVD_COUNT_FIVE(0.00)[5]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.20)[multipart/signed,multipart/mixed,text/plain]; RCVD_TLS_LAST(0.00)[]; ARC_ALLOW(-1.00)[microsoft.com:s=arcselector9901:i=1]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[40.92.42.53:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[40.92.42.53:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[40.92.42.53:from]; MAILMAN_DEST(0.00)[freebsd-questions] X-Mailman-Approved-At: Tue, 15 Jun 2021 05:23:49 +0000 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: Mon, 14 Jun 2021 21:10:34 -0000 --LGwTt1xj1LKnYCBVxoiegy1f8qZiYRC1p Content-Type: multipart/mixed; boundary="y92VoQwPpesYOhlfQQd8DmThc5KmxdnyL"; protected-headers="v1" From: "Edward Sanford Sutton, III" To: freebsd-questions@freebsd.org Message-ID: <9d793a27-659e-7b0a-ad9e-6eee34c2dc62@hotmail.com> Subject: Why doesn't cc -ansi disable conflicting type for getline from stdio.h? --y92VoQwPpesYOhlfQQd8DmThc5KmxdnyL Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Trying to work on properly learning C so following K&R second edition of C Programming Language. Found in manpage that -std=3Dc89 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 >=3D 200809" should trigger as true in there with -std=3Dc89? Section 1.9 page 29 uses that function name in its own sample= code. I know I could rename it, but is there a way to disable this book to modern compiler incompatibility from command line as I was attempting? I've tried to call the compiler executable directly and also attempted with /usr/local/bin/clang10 without different results. I tried to disable ccache from environment variable setting but don't know how to tell if that took effect properly nor would I expect it should be relevant. If you have a different starting suggestion for learning C then I'd be interested but it seemed to be the guidance I found with internet searching and other starter books I own usually mix c and c++ with more of a c++ and nonunix focus. Also trying to work on learning vi while doing this; hard to wrap my brain around insert (sometimes?) backing me up 1 character when exiting the mode. If helpful I can include the code I typed form the page of text, or a smaller example showing the problem. Below is compiler command with output and /usr/lib/clang/11.0.1/include does not have a copy of stdio.h that I see. /usr/bin/clang -ansi -v characterarrays.c FreeBSD clang version 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe) Target: x86_64-unknown-freebsd13.0 Thread model: posix InstalledDir: /usr/bin "/usr/bin/clang" -cc1 -triple x86_64-unknown-freebsd13.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name characterarrays.c -mrelocation-model static -mframe-pointer=3Dall -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=3Dgdb -v -resource-dir /usr/lib/clang/11.0.1 -std=3Dc89 -fdebug-compilation-dir /home/mirror176/programming/k&r -ferror-limit 19 -fgnuc-version=3D4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/characterarrays-a7e144.o -x c characterarrays.c clang -cc1 version 11.0.1 based upon LLVM 11.0.1 default target x86_64-unknown-freebsd13.0 #include "..." search starts here: #include <...> search starts here: /usr/lib/clang/11.0.1/include /usr/include End of search list. characterarrays.c:4:5: error: conflicting types for 'getline' int getline(char line[], int maxline); ^ /usr/include/stdio.h:380:10: note: previous declaration is here ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict); ^ characterarrays.c:16:37: error: too few arguments to function call, expected 3, have 2 while ((len =3D getline(line, MAXLINE)) > 0) ~~~~~~~ ^ /usr/include/stdio.h:380:10: note: 'getline' declared here ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict); ^ characterarrays.c:27:5: error: conflicting types for 'getline' int getline(char a[], int lim) ^ /usr/include/stdio.h:380:10: note: previous declaration is here ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict); ^ characterarrays.c:31:45: error: use of undeclared identifier 'c1' for (i=3D0; i