Garance A Drosihn wrote:
> >How does one fix this in a library?  I've been moving the
> >initialization to main() for applications.
> If all else fails, have some global static variable, and check
> the value in the routine(s) which care.  if the flag variable
> is still zero, then initialize the stdout variable and change
> the flag variable to 1.
> I imagine there's plenty of smarter ways to do it though.

The smartest way would be to have "all zeros" be the correct
default for the initial state data.

The next smartest way would be to pick the first zeroed value
as an "initialized" variable, and check it each time, setting
it to 1, once the initialization has taken place.

The next smartest way would be to treat it as if it were a static
class declaration that needed to be automatically constructed
before it could be used (see the code for this in my previous
posting).  This one is kind of a tossup, since it gets the
extra check out of the main path, but relies on weird glue code.

The least smartest way would be to create an init function which
had to be called by main() before you could use stdio, unlike all
other UNIX systems on the planet.

-- Terry

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to