Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!brunix!sdm From: sdm@cs.brown.edu (Scott Meyers) Newsgroups: comp.lang.c++ Subject: Mixing C and C++ Message-ID: <72092@brunix.UUCP> Date: 14 Apr 91 21:39:19 GMT Sender: news@brunix.UUCP Reply-To: sdm@cs.brown.edu (Scott Meyers) Organization: Brown University Department of Computer Science Lines: 23 Suppose I'm writing a program in both C and C++, and I've got globals requiring compile-time initialization in both. Then both languages will want to own "main" (i.e., have main written in their language). Is there a nice way to solve this problem, particularly if, say I'm including two read-only modules, one in each language (i.e., I can't change the source)? I assume that both languages generate a routine "real_main" (often called _main) that looks like this: real_main() { initialize_globals(); main(); cleanup_after_globals(); } However, only one real_main() will get called, the one belonging to whichever language writes main. Is there a portable solution? Scott ------------------------------------------------------------------------------- What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."