home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19958 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.6 KB  |  37 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!hal.com!olivea!spool.mu.edu!agate!doc.ic.ac.uk!warwick!uknet!axion!planet.bt.co.uk!njs
  2. From: njs@planet.bt.co.uk (Non NIS Account)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help with the linking of C and C++ files.
  5. Keywords: C++ object C link
  6. Message-ID: <1993Jan26.150502.19132@planet.bt.co.uk>
  7. Date: 26 Jan 93 15:05:02 GMT
  8. References: <1993Jan22.053408.14225@gmuvax2.gmu.edu>
  9. Sender: news@planet.bt.co.uk
  10. Organization: DNM42, BT Labs, Martlesham Heath, Ipswich, UK.
  11. Lines: 23
  12. Originator: njs@andromeda
  13.  
  14.  
  15. In article <1993Jan22.053408.14225@gmuvax2.gmu.edu>, mbenson@gmuvax2.gmu.edu (Michael Benson) writes:
  16. |> I need some help.
  17. |> 
  18. |> I have a piece of code which I know compiles correctly into an object
  19. |> file.  The code is in the Microsoft C language.  It has a header file
  20. |> that properally defines the prototypes.  
  21. |> 
  22. |> I include the header  file in a new program that is written in Borland
  23. |> C++ (version 3.1).  It compiles fine, but fails to link.  It gives the
  24. |> error "undefined symbol xxxxx in module xxx.cpp"  I know that for some
  25. |> reason the linker doesn't want to recognize the code in the c routine.
  26. |> I have tried (maybe naively) to use extern "C" with the header file, but
  27. |> that failed. 
  28.  
  29. That should work.  What one normally expects to see is something like:
  30.  
  31. extern "C"
  32. { int function ( args );
  33. }
  34. In the header file of the c++ using the c code.  The c code is compiled seperately as c code and then linked as a c library.  If it is kosher ansi c though it should compile as c++ code so you should not have a problem if you just compile it as c++ - the linker won't care then.
  35.  
  36. Nathan
  37.