|
Boost Users : |
From: Nigel Rantor (wiggly_at_[hidden])
Date: 2005-10-21 09:28:22
Simon Buchan wrote:
> In random.h,
>
> static rng_type rng;
>
> (which says, 'make this variable invisible to other object files')
> should be
>
> extern rng_type rng;
>
> (which says, 'declare this, but don't define it')
> and random.cpp should have
>
> rng_type rng;
>
> or else each translation unit (source file) will have it's own rng,
> meaning when you seed rng in test.cpp, random.cpp's rng is not seeded,
> meaning, of course, that rng() in test.cpp will give random numbers, but
> rng() in random.cpp will (ironicly) not give random numbers.
>
> And don't worry too much about this, linkage issues /are/ confusing.
Gah! Thank you. I have been tainted by too much Java.
Well, you win the competition then, I owe you a beer, or two.
On slight tangent, do you think that the way I've done this makes sense
or is there a better way of wrapping the random functionalit so I can
easily get numbers in whatever range I want?
n
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net