From owner-freebsd-chat Fri Feb 25 18:24:38 2000 Delivered-To: freebsd-chat@freebsd.org Received: from csla.csl.sri.com (csla.csl.sri.com [192.12.33.2]) by hub.freebsd.org (Postfix) with ESMTP id 21AE637BDCF for ; Fri, 25 Feb 2000 18:24:34 -0800 (PST) (envelope-from molter@csl.sri.com) Received: from sofia.csl.sri.com (sofia.csl.sri.com [130.107.18.127]) by csla.csl.sri.com (8.9.1/8.9.1) with ESMTP id SAA05286 for ; Fri, 25 Feb 2000 18:24:32 -0800 (PST) From: Marco Molteni Received: (from molter@localhost) by sofia.csl.sri.com (8.9.3/8.8.7) id SAA05035 for freebsd-chat@freebsd.org; Fri, 25 Feb 2000 18:24:32 -0800 (PST) Date: Fri, 25 Feb 2000 18:24:32 -0800 To: freebsd-chat@freebsd.org Subject: how to do this C preprocessor trick? Message-ID: <20000225182432.A5017@sofia.csl.sri.com> Mail-Followup-To: freebsd-chat@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre4i Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hi all, I have a function that takes a variable number of arguments: void d_printf(const char *format, ...) I would like to make it print automatically the function name from which it is called, eg instead of doing f() { d_printf("f: blabla", x, y, z); } doing simply f() { d_printf("blabla", x, y, z); } To do that, I though of wrapping d_printf() around a macro like #define dprintf(x) d_printf(__FUNCTION__, x) but whatever combination I use (also with #), the thing is not going to work: main.c:231: macro `d_printf' used with too many (4) args Is it possible to trick the C preprocessor to do what I want? Thanks Marco -- Marco Molteni "rough consensus and running code" SRI International, System Design Laboratory To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message