home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!europa.asd.contel.com!emory!wupost!usc!news!lsi!mhost!cl301!ameesh
- From: ameesh@lsil.com (Ameesh Desai)
- Newsgroups: comp.lang.c++
- Subject: Re: Linking C++ and C
- Message-ID: <1992Nov13.211854.6149@lsil.com>
- Date: 13 Nov 92 21:18:54 GMT
- References: <1992Nov11.141726.22547@cucs5.cs.cuhk.hk>
- Sender: news@lsil.com (news caster)
- Reply-To: ameesh@lsil.com
- Organization: LSI Logic Corporation
- Lines: 36
- Nntp-Posting-Host: cl301
-
- In article 22547@cucs5.cs.cuhk.hk, hclam@cuse1.se.cuhk.hk (LAM Ho Cheong) writes:
- >I got a problem of linking C & C++ programs using the Turbo C++ for
- >Windows on PC. I'm going to link some C source codes and some C++
- >source codes. I need to invoke certain C-like functions defined in a C++
- >codes in a C codes. However, the linker replies me that no such functions
- >have been declared. That means the functions defined in the C++ codes are
- >not accessable from the C codes. Can anyone give me some advice?
- >
- >test1.cpp test2.c
- >.... main()
- >void f(void) {
- >{ ...
- > printf("Hello, World\n"); f();
- >} ...
- >.... }
- >
- >linker error: "function _f is not declared in module "test2.c""!
- >
- >It's natural because I'm using some more advanced stuff (C++) by a less
- >advanced stuff (C). But, I need to solve this ...
- >
- >I'll appreciate any advice sent to me at hclam@se.cuhk.hk
- >
- >Thanks in advance.
-
-
- Use extern "C" linkage specification for defining f() in test1.cpp
-
-
- Ameesh
- ---
- ______________________________ o__
- | _ /| Ameesh Desai \ ,>/_
- | \`O.o' LSI Logic Corp. \__(_)`(_)_ email: ameesh@lsil.com
- | =(_|_)= MS E192, 1501 McCarthy Blvd. \ fax : (408) 433-6802
- |____U_______Milpitas, CA 95035____________\____________voice: (408) 433-4097
-