Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!usc!aero!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!ucla-cs!uci-ics!news From: schmidt@glacier.ics.uci.edu (Doug Schmidt) Newsgroups: gnu.g++.bug Subject: fun fax to know and tell Message-ID: <1989Oct4.061118.16060@paris.ics.uci.edu> Date: 4 Oct 89 06:11:18 GMT Sender: news@paris.ics.uci.edu (Network News) Reply-To: schmidt@glacier.ics.uci.edu (Doug Schmidt) Distribution: gnu Organization: University of California, Irvine - Dept of ICS Lines: 29 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 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.