From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout-kit-01.scc.kit.edu (scc-mailout-kit-01.scc.kit.edu [129.13.231.81]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 3dba0dc8 for ; Tue, 10 Sep 2019 12:47:11 -0500 (EST) Received: from asta-nat.asta.uni-karlsruhe.de ([172.22.63.82] helo=hekate.usta.de) by scc-mailout-kit-01.scc.kit.edu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (envelope-from ) id 1i7kEP-0000qO-7q; Tue, 10 Sep 2019 19:47:10 +0200 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.77) (envelope-from ) id 1i7kEN-0002Wx-Nm; Tue, 10 Sep 2019 19:47:07 +0200 Received: from athene.usta.de ([172.24.96.10]) by donnerwolke.usta.de with esmtp (Exim 4.84_2) (envelope-from ) id 1i7kEM-0003UN-9F; Tue, 10 Sep 2019 19:47:06 +0200 Received: from localhost (athene.usta.de [local]) by athene.usta.de (OpenSMTPD) with ESMTPA id c1c6d5d5; Tue, 10 Sep 2019 19:47:07 +0200 (CEST) Date: Tue, 10 Sep 2019 19:47:07 +0200 From: Ingo Schwarze To: Yuri Pankov Cc: discuss@mandoc.bsd.lv Subject: Re: "WARNING: parenthesis in function name" correctness Message-ID: <20190910174707.GD6626@athene.usta.de> References: <421eeed3-8da5-b852-4581-1058de113831@yuripv.net> X-Mailinglist: mandoc-discuss Reply-To: discuss@mandoc.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <421eeed3-8da5-b852-4581-1058de113831@yuripv.net> User-Agent: Mutt/1.8.0 (2017-02-23) Hi Yuri, Yuri Pankov wrote on Tue, Sep 10, 2019 at 11:20:24AM +0300: > I'm looking into fixing sbuf.9 which currently has somewhat unreadable: > > .Ft typedef\ int ( sbuf_drain_func ) ( void\ *arg, const\ char\ *data, > int\ len ) ; Indeed, that is horrible and should be fixed. > ...into somewhat nicer: > > .Ft typedef int > .Fo (sbuf_drain_func) > .Fa "void *arg" > .Fa "const char *data" > .Fa "int len" > .Fc > > ...but that gives me a: > > mandoc: share/man/man9/sbuf.9:69:5: WARNING: parenthesis in function > name: (sbuf_drain_func) > > Looking at the code, parenthesis are only allowed in the following form: > > .Ft (*func_ptr) I think you mean .Fo/.Fn, not .Ft, right? > ...while here we don't have a "*" -- it's the way it's typedef'ed in the > source, and I want to follow it, so I wonder if that check/warning is > really useful. If i understand the C standard correctly (otherwise, please somebody correct me!), we have: int (f)() -- function returning int int (*fp)() -- pointer to function returning int In many situations, both can be used interchangeably, consider for example C89 3.2.2.1: "A function designator is an expression that has function type. Except when it is the operand of the sizeof operator or the unary & operator, a function designator with type ``function returning type'' is converted to an expression that has type ``pointer to function returning type.''" Then again, it seems for sizeof(), it may make a difference whether a type is a function type or a function pointer type, and maybe there are also other situations where that matters. So i suspect you are right there are legitimate reasons for making the difference in the documentation, too, and saying ".Fo (sbuf_drain_func)" looks reasonable. Do others agree? I plan to suppress the warning for ".Fo (f)" just like for ".Fo (*f)" in the future. The likely typo that should be warned about is ".Fo f()", and that warning will still work. Yours, Ingo -- To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv