| delorie.com/archives/browse.cgi | search |
| From: | "Lars Hansen" <lars DOT o DOT hansen AT gmx DOT de> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: several questions (symify, dynamic labels, cpu clock) |
| Date: | Tue, 21 Jan 2003 20:37:15 +0100 |
| Organization: | 1&1 Internet AG |
| Lines: | 48 |
| Message-ID: | <b0k7hd$fus$1@news.online.de> |
| References: | <b0ff15$lql$1 AT news DOT online DOT de> <b0je70$5ui$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <b0jp6g$7b9$1 AT news DOT online DOT de> <b0jpn5$7hi$1 AT news DOT online DOT de> <3E2D7CEE DOT A3C6D7FC AT phekda DOT freeserve DOT co DOT uk> |
| NNTP-Posting-Host: | p50838a4d.dip0.t-ipconnect.de |
| X-Trace: | news.online.de 1043177837 16348 80.131.138.77 (21 Jan 2003 19:37:17 GMT) |
| X-Complaints-To: | abuse AT online DOT de |
| NNTP-Posting-Date: | 21 Jan 2003 19:37:17 GMT |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 6.00.2800.1106 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2800.1106 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
> > And sometimes I need code just to execute the first time but that code is
> > part of code in a function which itself may or may not be called during
> > program execution (or other such 1st time only not cases).
>
> Why not split the "first time called" code out into a separate function and
> then call that from multiple places?
>
> void
> foo (void)
> {
> static int foo_inited = 0;
>
> if (foo_inited)
> return;
>
> foo_inited++;
> ...
> }
>
> void
> function_that_may_or_may_not_be_called (void)
> {
> foo();
> ...
> }
>
> int
> main (void)
> {
> foo();
> ...
> }
I want to avoid any "if"s.
so
goto *dynapointer;
label1: do_some_stuff;
*dynapointer=&&label2;
label2: do_normal_stuff
but in order to make full use of it I need the address of label1 before I'm
there the first time (and it might also be necessary to set dynapointer to
label1 again at a later time).
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |