From owner-freebsd-hackers Thu Oct 26 14:52:03 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id OAA28782 for hackers-outgoing; Thu, 26 Oct 1995 14:52:03 -0700 Received: from irz301.inf.tu-dresden.de (irz301.inf.tu-dresden.de [141.76.1.11]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id OAA28745 for ; Thu, 26 Oct 1995 14:51:43 -0700 Received: from sax.sax.de by irz301.inf.tu-dresden.de (8.6.12/8.6.12-s1) with ESMTP id WAA17570; Thu, 26 Oct 1995 22:50:51 +0100 Received: by sax.sax.de (8.6.11/8.6.12-s1) with UUCP id WAA16547; Thu, 26 Oct 1995 22:50:51 +0100 Received: (from j@localhost) by uriah.heep.sax.de (8.6.12/8.6.9) id WAA29123; Thu, 26 Oct 1995 22:37:33 +0100 From: J Wunsch Message-Id: <199510262137.WAA29123@uriah.heep.sax.de> Subject: Re: cpp question To: phk@critter.tfs.com (Poul-Henning Kamp) Date: Thu, 26 Oct 1995 22:37:33 +0100 (MET) Cc: hackers@freebsd.org Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <673.814700238@critter.tfs.com> from "Poul-Henning Kamp" at Oct 26, 95 10:37:18 am X-Phone: +49-351-2012 669 X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Content-Length: 740 Sender: owner-hackers@freebsd.org Precedence: bulk As Poul-Henning Kamp wrote: > > > My new testament is at home, can somebody tell me in the meantime: > > What do I write in a macro to make a token a string ? > > I want to do something like this: > > #define FOO(ptr,fmt,name) \ > printf("%s =" fmt "\n", XXXX, (ptr)->name) > > What do I need to put at XXXX ? to convert the name to "name" ? #define FOO(ptr,fmt,name) \ printf("%s =" fmt "\n", # name, (ptr)->name) or simpler: #define FOO(ptr,fmt,name) \ printf(# name " =" fmt "\n", (ptr)->name) (ANSI mandates that "foo" "bar" yields the single string "foobar".) -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)