[gnu.g++.bug] fun fax to know and tell

schmidt@glacier.ics.uci.edu (Doug Schmidt) (10/04/89)

Here is a semi-interesting new C++ 2.0 feature to g++ 1.36.0-.  It is
now possible to initialize global and static variables with
non-constant expressions (unlike C and cfront 1.2).

----------------------------------------
#include <stdio.h>

extern "C" int time (void *);
extern "C" int srand (int);
extern "C" int rand (void);

/* Initialize global variable via arbitrary function call... */
int random_number = int (srand (time (0)), rand ());

main ()
{
  printf ("random number = %d\n", random_number);
}
----------------------------------------

I've not yet found a pressing need to incorporate this into any code,
but I'm sure there are applications for it...

Doug
--
schmidt@ics.uci.edu (ARPA) |   Per me si va nella citta' dolente.
office: (714) 856-4043     |   Per me si va nell'eterno dolore.
                           |   Per me si va tra la perduta gente.
                           |   Lasciate ogni speranza o voi ch'entrate.