From owner-freebsd-questions@FreeBSD.ORG Mon Jun 1 12:28:18 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 389C910656CF for ; Mon, 1 Jun 2009 12:28:18 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from muon.cran.org.uk (brucec-1-pt.tunnel.tserv4.nyc4.ipv6.he.net [IPv6:2001:470:1f06:c09::2]) by mx1.freebsd.org (Postfix) with ESMTP id E836F8FC19 for ; Mon, 1 Jun 2009 12:28:17 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from muon.cran.org.uk (localhost [127.0.0.1]) by muon.cran.org.uk (Postfix) with ESMTP id 6A27319235; Mon, 1 Jun 2009 12:28:16 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on muon X-Spam-Level: X-Spam-Status: No, score=-2.6 required=8.0 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.2.5 Received: from gluon.draftnet (unknown [IPv6:2a01:348:10f:0:240:f4ff:fe57:9871]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by muon.cran.org.uk (Postfix) with ESMTPSA; Mon, 1 Jun 2009 12:28:16 +0000 (GMT) Date: Mon, 1 Jun 2009 13:28:12 +0100 From: Bruce Cran To: =?utf-8?Q?Ond=C5=99ej?= Majerech Message-ID: <20090601132812.12d93819@gluon.draftnet> In-Reply-To: References: <20090531223136.GA9212@thought.org> X-Mailer: Claws Mail 3.7.1 (GTK+ 2.16.1; i386-portbld-freebsd7.2) Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: Gary Kline , FreeBSD Mailing List Subject: Re: how to i designate the current function...? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jun 2009 12:28:19 -0000 On Mon, 01 Jun 2009 00:53:39 +0200 Ond=C5=99ej Majerech wrote: > On Mon, 01 Jun 2009 00:31:40 +0200, Gary Kline > wrote: >=20 > > I'm not sure this is std yet, but think it is available in > > gcc. If I'm calling funtion bar(char *, char) with one of the args > > incorrect, is there a way to have gcc name bar() in an > > error message? > > >=20 > Are you looking for the __FUNCTION__ macro? >=20 > void baz( char yes_no ) { > if ( yes_no =3D=3D 'Y' || yes_no =3D=3D 'N' ) { > // Do stuff... > } else { > printf( "%s: %s\n", __FUNCTION__, "I got an invalid arg" ); > } > } >=20 > AFAIK, this isn't standard C, but well supported on GCC. __FUNCTION__ is commonly supported, but has never been standardised; C99 defines __func__ instead. See http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html for details. --=20 Bruce Cran