Article View: gnu.g++.bug
Article #468fun fax to know and tell
From: Doug Schmidt
Date: Wed, 04 Oct 1989 06:11
Date: Wed, 04 Oct 1989 06:11
29 lines
1534 bytes
1534 bytes
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.
Technical Details
Message-ID:
<1989Oct4.061118.16060@paris.ics.uci.edu>Path:
arc1-ca.pugleaf.net!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!newsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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