From owner-freebsd-hackers Wed Jul 22 07:51:49 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA14298 for freebsd-hackers-outgoing; Wed, 22 Jul 1998 07:51:49 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: (from jmb@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA14189; Wed, 22 Jul 1998 07:51:27 -0700 (PDT) (envelope-from jmb) From: "Jonathan M. Bresler" Message-Id: <199807221451.HAA14189@hub.freebsd.org> Subject: Re: macro expansion with gcc In-Reply-To: <199807221444.KAA00397@lakes.dignus.com> from Thomas David Rivers at "Jul 22, 98 10:44:47 am" To: rivers@dignus.com (Thomas David Rivers) Date: Wed, 22 Jul 1998 07:51:23 -0700 (PDT) Cc: hackers@hub.freebsd.org, jmb@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL32 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Thomas David Rivers wrote: > > > > gcc -E runs the preprocessor, so i expected that all macros > > would be expanded....but thats not what happened. > > > > what switch do i need to get the token pasting "##" > > operation to take effect and leave behind the C code? > > > > > > jmb > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > with "unsubscribe freebsd-hackers" in the body of the message > > > > It should have expanded everything... token pasting is a little > tricky though..., so it may not be pasting the way you expect. > [I know I, personally, frequently get this wrong.] Can you point us > to an example where it didn't seem to do the expansion? will do. /sys/kern/kern_clock.c contains: SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW, 0, ""); SYSCTL_PROC(_kern_timecounter, OID_AUTO, frequency, CTLTYPE_INT | CTLFLAG_RW, 0, sizeof(u_int), sysctl_kern_timecounter_frequency, "I", ""); SYSCTL_PROC(_kern_timecounter, OID_AUTO, adjustment, CTLTYPE_INT | CTLFLAG_RW, 0, sizeof(int), sysctl_kern_timecounter_adjustment, "I", ""); which "cd /sys/kern; gcc -E kern_clock.c" expands to: SYSCTL_NODE(_kern, (-1) , timecounter, (0x80000000 | 0x40000000 ) , 0, ""); SYSCTL_PROC(_kern_timecounter, (-1) , frequency, 2 | (0x80000000 | 0x40000000 ) , 0, sizeof(u_int), sysctl_kern_timecounter_frequency, "I", ""); SYSCTL_PROC(_kern_timecounter, (-1) , adjustment, 2 | (0x80000000 | 0x40000000 ) , 0, sizeof(int), sysctl_kern_timecounter_adjustment, "I", ""); defining KERNEL......grrr.....make all the difference in the world! sorry to have bothered you all ;) extern struct linker_set sysctl__kern_timecounter ; static const struct sysctl_o id sysctl___kern_timecounter = { (-1) , 1 | (0x80000000 | 0x40000000 ) , (void*)&sysctl__kern_timecounter , 0 , "timecounter", 0 , "N" }; static void const * const __set_sysctl__kern_sym_sysctl___kern_timecounter = & sysctl___kern_timecounter ; __asm(".stabs \"_" "sysctl__kern" "\", " "23" ", 0, 0, _" "sysctl___kern_timecounter") ; static void const * const __ set_sysctl__kern_timecounter_sym_sysctl___kern_timecounter = & sysctl___ke rn_timecounter ; __asm(".stabs \"_" "sysctl__kern_timecounter" "\", " "23" ", 0, 0, _" "sysctl___kern_timecounter") ; etc... jmb To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message