Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!odi!dlw From: dlw@odi.com (Dan Weinreb) Newsgroups: comp.lang.c++ Subject: Re: Using C++ AND C together Message-ID: <1989Sep15.215536.20858@odi.com> Date: 15 Sep 89 21:55:36 GMT References: <953@ncratl.Atlanta.NCR.COM> <6590251@hplsla.HP.COM> <6497@columbia.edu> Reply-To: dlw@odi.com Organization: Object Design, Inc. Lines: 16 In-reply-to: kearns@read.columbia.edu's message of 14 Sep 89 01:03:05 GMT In article <6497@columbia.edu> kearns@read.columbia.edu (Steve Kearns) writes: Is it possible to link a C program with a C++ library? The only a priori problem I could see is that the c++ global constructors would not be properly inited. Yes, that's the main problem. One way around the problem is to include a small C++ program that defines "main" and calls another function, called something like "cmain", passing all the arguments. Then the C program uses the name "cmain" where it would have used "main", to define its top-level function. Then you use CC as the linker. This is kludgey, of course, but it's simple and it works. You probably also want to provide a header file that defines a bunch of nice, readable names to expand into the mangled names produced by cfront.