How to include c project into vc++ project.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: How to include c project into vc++ project.

  1. #1
    Join Date
    Mar 2010

    How to include c project into vc++ project.

    Hi all,
    I have a DOS application that was written in C. Since it's DOS, I'm creating a GUI for the application in VC++ but would like to use all the original functions from the .C and .H files. Can I include these in my VC++ project or do I need to modify them? There are 13 projects to include in my VC++ GUI project.

    thanks ,

  2. #2
    Join Date
    Oct 2009

    Smile Re: How to include c project into vc++ project.

    Yes, you can include the headers and c sources to your VC++ project. In all C++ sources and headers you should add extern "C" clause to prevent from C++ name mangling.

    extern "C"
    #include "oldc_header"
    Alternatively, you put that clause into the old headers like

    // old header
    #ifndef OLD_HEADER_H
    #ifdef __cplusplus
    extern "C"
    // put here the olc contents of the header
    #ifdef __cplusplus
    #endif // OLD_HEADER_H
    That way the extern "C" only applies if the header was included from C++ source and the old C sources would compile as well including the header.

  3. #3
    Join Date
    Oct 2006

    Re: How to include c project into vc++ project.

    An addendum to that.
    You also have to make sure you compile the C source with a C-compiler instead of a C++ compiler. I think the default setting for Visual Studio does that but if you run into some linker issues that might be worth to check.
    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

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 is a survey!

HTML5 Development Center