delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/01/21/12:15:08

From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: several questions (symify, dynamic labels, cpu clock)
Date: Tue, 21 Jan 2003 17:01:34 +0000
Lines: 48
Message-ID: <3E2D7CEE.A3C6D7FC@phekda.freeserve.co.uk>
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>
NNTP-Posting-Host: 62.136.7.238
Mime-Version: 1.0
X-Trace: news6.svr.pol.co.uk 1043168819 11202 62.136.7.238 (21 Jan 2003 17:06:59 GMT)
NNTP-Posting-Date: 21 Jan 2003 17:06:59 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello.

Lars Hansen wrote:
> 
> > > > 2. how can I get the address of a dynamic label which is in a
> > > > function I am not in?
> > >
> > > Don't worry --- it wouldn't be useful for anything, even if you could.
> > > Dynamic labels are not meant as a substitute for longjmp() or plain
> > > function calls.
> 
> 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();
  ...
}

Regards,

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019