[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

2085.0. "Alter goto is there one ...?" by KERNEL::PULLEY (Come! while living waters flow) Wed Feb 05 1997 12:38

    Hi,
    
    Is there something like a changeable goto?
    Don't worry if there isn't, I'd just like to know.
    What I'm trying to do is add some debugging functions to my program.
    I didn't want to necessarily run it in debug, but just to get the
    functions to execute if a variable was set--so during the program
    they'd
    either always run, or always not.
    Now I can do something like:-
    if (debug variable set)
    the_debug_function();
    but that tests every time which may not be necessary.
    So is there a way I can:-
    If (debug variable set)
    thelabel=debuglabel;
    else
    thelabel=nodebuglabel
    ...
    goto thelabel;
    debuglabel: the_debug_function();
    nodebuglabel: ...
    
    Thanks,
    Steve.
    
T.RTitleUserPersonal
Name
DateLines
2085.1Use a function variable?WIBBIN::NOYCEPulling weeds, pickin' stonesWed Feb 05 1997 12:5612
How about
	void ret() {};
	void debugfunc() {printf("whatever...\n";)
	:
	void (*thefunc)();
	:
	If (debug variable set)
	    thefunc=debugfunc;
	else
	    thefunc=ret;
	:
	thefunc();