Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!wuarchive!uunet!dptechno!cw From: cw@dptechno.UUCP (Charles Haden) Newsgroups: comp.lang.c++ Subject: Re: C/C++ link in TC++ Message-ID: <577@dptechno.UUCP> Date: 12 Sep 90 17:51:01 GMT References: <4800101@m.cs.uiuc.edu> Reply-To: cw@dptechno.UUCP (Charles Haden) Organization: D.P. Technology Corp. Camarillo California Lines: 35 In article <4800101@m.cs.uiuc.edu> reed@m.cs.uiuc.edu writes: > > >I've been trying to link C object modules with C++, both created >using Turbo C++. I must be doing something stupid, because the >Turbo linker is unable to find the C reference. I've attached a >code sample below that fails when I do the following: > > tcc -c y.c > tcc -c x.cpp y.obj > >This fails to resolve the reference to "try" > >Any ideas on what I'm overlooking? Your main problem lies primarily in the command line invocations of the compiler. What I mean by that is your problem is not in your source code it is in the way you are using the compiler. As you should know from the manuals that you can compile both "C" and "C++" source code with the compiler. What you probably didn't read it that the compiler treats prototyping differently based on the file extension ( default setting ). When compilling a C++ source file, the function name is "tweaked" you might say internally to allow for function overloading. This tweaking is not normally done to standard C source code prototypes, since overloading of function names is not allowed. There is a switch however, that will force standard C source files to be tweaked when compiling. ( see below ) A note of caution : this switch can only be used when you have the source code and re-compile it. Proper command line invocations ( tested with omitted source. ) : tcc -c -P y.c tcc x.cpp y.obj