home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16256 < prev    next >
Encoding:
Text File  |  1992-11-14  |  1.9 KB  |  50 lines

  1. Path: sparky!uunet!europa.asd.contel.com!emory!wupost!usc!news!lsi!mhost!cl301!ameesh
  2. From: ameesh@lsil.com (Ameesh Desai)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Linking C++ and C
  5. Message-ID: <1992Nov13.211854.6149@lsil.com>
  6. Date: 13 Nov 92 21:18:54 GMT
  7. References: <1992Nov11.141726.22547@cucs5.cs.cuhk.hk>
  8. Sender: news@lsil.com (news caster)
  9. Reply-To: ameesh@lsil.com
  10. Organization: LSI Logic Corporation
  11. Lines: 36
  12. Nntp-Posting-Host: cl301
  13.  
  14. In article 22547@cucs5.cs.cuhk.hk, hclam@cuse1.se.cuhk.hk (LAM Ho Cheong) writes:
  15. >I got a problem of linking C & C++ programs using the Turbo C++ for
  16. >Windows on PC. I'm going to link some C source codes and some C++ 
  17. >source codes. I need to invoke certain C-like functions defined in a C++
  18. >codes in a C codes. However, the linker replies me that no such functions
  19. >have been declared. That means the functions defined in the C++ codes are
  20. >not accessable from the C codes. Can anyone give me some advice?
  21. >
  22. >test1.cpp                          test2.c
  23. >....                                main()
  24. >void f(void)                       {
  25. >{                                     ...
  26. >    printf("Hello, World\n");         f();
  27. >}                                     ...
  28. >....                                }
  29. >
  30. >linker error: "function _f is not declared in module "test2.c""!
  31. >
  32. >It's natural because I'm using some more advanced stuff (C++) by a less 
  33. >advanced stuff (C). But, I need to solve this ...
  34. >
  35. >I'll appreciate any advice sent to me at hclam@se.cuhk.hk
  36. >
  37. >Thanks in advance.
  38.  
  39.  
  40. Use extern "C" linkage specification for defining f() in test1.cpp
  41.  
  42.  
  43. Ameesh
  44. ---
  45. ______________________________     o__            
  46. | _   /|     Ameesh Desai     \    ,>/_                              
  47. | \`O.o'     LSI Logic Corp.   \__(_)`(_)_              email: ameesh@lsil.com
  48. | =(_|_)=    MS E192, 1501 McCarthy Blvd. \             fax  : (408) 433-6802
  49. |____U_______Milpitas, CA 95035____________\____________voice: (408) 433-4097 
  50.