on1 construct

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Thu Nov 8 02:29:49 AEST 1984


> I've started functions in the following way:
> 
> function ()
> {
>     static char first_time_in = TRUE;
> 
>     if (first_time_in)  {
>         first_time_in = FALSE;
> 	bla, bla, bla...
>     };
> 
>     etc...
> }
> 
> One contruct that I've always wanted to have is:
> 
> function ()
> {
>     on1  {
> 	bla, bla, bla...
>     };
> 
>     etc...
> }
> 
> I've been trying to define a macro to do this but haven't been succesful.

Try:

#define	on1	static long on1_flag = 0L; if ( on1_flag++ == 0L )

There are other tricks if you don't like this one.  Remember, the
condition inside the "if" parentheses can accomplish as many side
actions as desired.



More information about the Comp.lang.c mailing list