Date: Wed, 22 Jul 1998 07:51:23 -0700 (PDT) From: "Jonathan M. Bresler" <jmb> To: rivers@dignus.com (Thomas David Rivers) Cc: hackers@hub.freebsd.org, jmb@FreeBSD.ORG Subject: Re: macro expansion with gcc Message-ID: <199807221451.HAA14189@hub.freebsd.org> In-Reply-To: <199807221444.KAA00397@lakes.dignus.com> from Thomas David Rivers at "Jul 22, 98 10:44:47 am"
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199807221451.HAA14189>