Boost logo

Boost Users :

From: Simon Buchan (simon_at_[hidden])
Date: 2005-10-20 22:28:03


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.


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