adding C file to existing project in vc++
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: adding C file to existing project in vc++

  1. #1
    Join Date
    Feb 2010

    adding C file to existing project in vc++


    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

  2. #2
    Join Date
    Apr 2008

    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

  3. #3
    Join Date
    Feb 2010

    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

  4. #4
    Join Date
    Oct 2006

    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
    #ifdef __cplusplus
    extern "C" {
    /* declarations */
    #ifdef __cplusplus
    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).
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    and before posting

    Refresh your memory on formatting tags here

    Get your free MS compiler here

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This a survey!

HTML5 Development Center