From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: scm_t_subr warnings Date: Fri, 01 Mar 2013 10:01:53 +0100 Message-ID: <87621ba3y6.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1362128795 5036 80.91.229.3 (1 Mar 2013 09:06:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Mar 2013 09:06:35 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Mar 01 10:06:59 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UBLve-0001K9-H8 for guile-devel@m.gmane.org; Fri, 01 Mar 2013 10:06:58 +0100 Original-Received: from localhost ([::1]:32936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBLvJ-0004wD-6y for guile-devel@m.gmane.org; Fri, 01 Mar 2013 04:06:37 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBLr2-0006Ac-2t for guile-devel@gnu.org; Fri, 01 Mar 2013 04:02:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBLqx-0003Nt-6b for guile-devel@gnu.org; Fri, 01 Mar 2013 04:02:12 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:46792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBLqx-0003Nh-06 for guile-devel@gnu.org; Fri, 01 Mar 2013 04:02:07 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UBLrG-00067e-39 for guile-devel@gnu.org; Fri, 01 Mar 2013 10:02:26 +0100 Original-Received: from reverse-83.fdn.fr ([80.67.176.83]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Mar 2013 10:02:26 +0100 Original-Received: from ludo by reverse-83.fdn.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 01 Mar 2013 10:02:26 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 65 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: reverse-83.fdn.fr X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 11 =?utf-8?Q?Vent=C3=B4se?= an 221 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu User-Agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:FYPEclbfd2uUW3KhMDvJoxohOj4= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15849 Archived-At: Hello, Julian Graham skribis: > Andy and Ludo and I were discussing this on IRC and it was suggested > that we move the question to the mailing list. I'm trying to compile > some code -- using `gcc -pedantic' -- that invokes `scm_c_make_gsubr', > and I'm getting the following warning: > > warning: ISO C forbids passing argument 5 of ‘scm_c_make_gsubr’ > between function pointer and ‘void *’ [-pedantic] > /usr/local/include/guile/2.0/libguile/gsubr.h:63:13: note: expected > ‘scm_t_subr’ but argument is of type ‘struct scm_unused_struct * > (*)(struct scm_unused_struct *, struct scm_unused_struct *)’ > > I was confused, because I was sure that Guile defines scm_t_subr as > `SCM (*) ()', meaning that an `scm_t_subr' is of unspecified arity. > And I was right, but only at libguile compilation time. From __scm.h: > > #ifdef BUILDING_LIBGUILE > typedef SCM (* scm_t_subr) (); > #else > typedef void *scm_t_subr; > #endif The rationale is given above in gsubr.h: /* The type of subrs, i.e., Scheme procedures implemented in C. Empty function declarators are used internally for pointers to functions of any arity. However, these are equivalent to `(void)' in C++, are obsolescent as of C99, and trigger `strict-prototypes' GCC warnings (bug #23681). */ (This refers to .) It is still an obsolescent feature as of C11. Would it work for you to just cast the argument to scm_t_subr? This is what snarf.h (and guile-snarf) does. > Thus the warning: ISO C lets you cast any kind of pointer to `void *' > -- except for a function pointer. [...] > #ifdef __cplusplus > typedef void *scm_t_subr > #else > typedef SCM (* scm_t_subr) (); > #endif > > What do you think? I think it’s not just C++, but also future C standards and current ‘-Wstrict-prototypes’. We can test for C++ or C > 11, but there’s no way do test for -Wstrict-prototypes or -pedantic. There’s #pragma GCC diagnostic, but it cannot be used here. So my current recommendation would be to add an explicit cast to scm_t_subr, unless someone has a better idea. Thanks, Ludo’.