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

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

  1. #1
    Join Date
    Feb 2010
    Posts
    18

    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

  2. #2
    Join Date
    Apr 2008
    Posts
    133

    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
    Posts
    18

    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
    Location
    Sweden
    Posts
    3,649

    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).
    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
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

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 Codeguru.com survey!


HTML5 Development Center