Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!halley!kelley From: kelley@halley.UUCP (Michael Kelley) Newsgroups: comp.lang.c++ Subject: cpp and _main() Keywords: cpp, initialization, macro replacement Message-ID: <1204@halley.UUCP> Date: 6 Dec 90 16:58:06 GMT Organization: Tandem Computers, Austin, TX Lines: 43 I've got a couple more questions. The first concerns pre-processing: is the text replacement for a macro containing a C++ style comment defined, or will it vary from cpp to cpp? That is, if I have an ostream for debugging, named cdbg, can I do this to take out the code when not debugging: #ifndef DEBUG extern ostream cdbg; #else #define cdbg // #endif I'll grant you it may not be that useful, since it will only work for expressions on one source line, but hey, I'm just curious. The second question is about AT&T's version cfront and the initialization performed in _main(). What would you say to passing it argc and argv, and having it call __main()? This new __main() would do what _main() does now--call the initializers in the _ctors list; then developers could provide their own version of _main. By publishing the name of your software's initialization routine--say, Gifts::intialize for our Graphical Interface For Tandem Systems, or NIH::Initialize--we could build software upon other libraries, perform all the necessary initialization, and do so without forcing the application developer to make all the right initialization calls. So if our group uses NIH (we don't), then our version of _main() becomes: void _main(int argc, char *argv[]) { __main(); NIH::Initalize(); Gifts::Initialize(argc, argv); } Global objects with constructors work fine for some things, but without having the order in which they are initialized defined, and given the need to access command-line arguments, I believe some scheme like this will be very beneficial. Comments? What are other C++ implementations doing for initialization? -- Mike Kelley Tandem Computers, Austin, TX halley!kelley@cs.utexas.edu (512) 244-8830