-
March 24th, 2010, 01:03 AM
#1
adding C file to existing project in vc++
hi,
I'm using msvc++ 6, and I'm using a huge code(application program) when code is built is workspace it shows only make file. And now i m going to add a .C file which ll contains some of functions.
i added c file: file-> new-> c++ source file-> filename.c
and when i do build its giving link error unresolved external symbol
unresolved external symbol is the function which i ve been used in C file
can some one help to cm out of this type of link error
-
March 24th, 2010, 02:03 AM
#2
Re: adding C file to existing project in vc++
you might need to turn off name mangling for the C functions using extern C if you want to call them in the C++ class
-
March 24th, 2010, 03:30 AM
#3
Re: adding C file to existing project in vc++
hi sunil_cguru,
i tried tht one also but all file are wth extension .c so v cant use externa C
-
March 24th, 2010, 01:53 PM
#4
Re: adding C file to existing project in vc++
If your linker say unresolved external .... function@@YAHH@Z then it expects your C file to be compiled as C++. If the @@ and so on is not present it expects it to be compiled as C++
Haven't got VC6 installed anymore but I'm pretty sure you can do the same as in later VS versions.
Right click on the file in question, select properties and then find the setting that say Compile As and select C. If the corresponding header file does not have a
Code:
#ifdef __cplusplus
extern "C" {
#endif
/* declarations */
#ifdef __cplusplus
}
#endif
add that. If the header doesn't have any #ifdef __cplusplus stuff you can also try switch to using the C++ compiler for all files (both .C and .CPP).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|