on1 construct
Bruce Karsh
karsh at geowhiz.UUCP
Sat Nov 10 06:44:05 AEST 1984
> One contruct that I've always wanted to have is:
>
> function ()
> {
> on1 {
> bla, bla, bla...
> };
>
> etc...
> }
It's a little cryptic, but here is one way to do it:
-- on1.c ------------- Cut Here -----------------------------------------
#define on1() static int notfirst= -1; if(!(++notfirst ? notfirst=1 : 0))
main()
{
sub();
sub();
sub();
}
sub()
{
on1()
printf("first time\n");
else
printf("not first time\n");
}
---------------------- Cut Here -----------------------------------------
--
Bruce Karsh ---------------------------
Univ. Wisconsin Dept. of Geology and Geophysics | |
1215 W Dayton, Madison, WI 53706 | THIS SPACE FOR RENT |
(608) 262-1697 | |
{ihnp4,seismo}!uwvax!geowhiz!karsh ---------------------------
More information about the Comp.lang.c
mailing list