CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2001
    Location
    germany
    Posts
    772

    include c file in c++ workspace (LNK2001 problem)

    Hi,

    I am having a dialog based MFC project and had to include a lot of c files from an older project. In one of the c files there is the only function which is supposed to be accessable from a .cpp file (the one implementing the dialog class). But I always get unresolved external symbol..
    Can you tell me how do I have to include non-MFC functions in order to work?
    I'm talking about the normal way to do that (suppose I have the file: a.c containing the function " test(char*, char*)" to be exported to file bDlg.cpp). How do I have to declare "test", etc.
    Then I'll check if I did it right..

    Thanks in advance!
    Please rate if it helps!

    * The second mouse gets the cheese.

    * Birthdays are good for you. The more you have, the longer you live.

    * Always keep your words soft and sweet, just in case you have to eat them.

    * Always read stuff that will make you look good if you die in the middle of it.

  2. #2
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: include c file in c++ workspace (LNK2001 problem)

    Code:
    #ifdef __cplusplus
    extern "C" int test(char*, char*); 
    #else
    int test(char*, char*); 
    #endif
    My hobby projects:
    www.rclsoftware.org.uk

  3. #3
    Join Date
    Jan 2003
    Location
    Cambridge, UK
    Posts
    752

    Re: include c file in c++ workspace (LNK2001 problem)

    I guess you might use extern "C" directive for C-style linkage
    Cheers,

    Alex
    Please rate this post if you find it helpful

  4. #4
    Join Date
    Aug 2001
    Location
    germany
    Posts
    772

    Re: include c file in c++ workspace (LNK2001 problem)

    That was it! Thanks guys!
    Please rate if it helps!

    * The second mouse gets the cheese.

    * Birthdays are good for you. The more you have, the longer you live.

    * Always keep your words soft and sweet, just in case you have to eat them.

    * Always read stuff that will make you look good if you die in the middle of it.

  5. #5
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: include c file in c++ workspace (LNK2001 problem)

    * The second mouse gets the cheese.

    * Birthdays are good for you. The more you have, the longer you live.

    * Always keep your words soft and sweet, just in case you have to eat them.

    * Always read stuff that will make you look good if you die in the middle of it.
    I like.

    My hobby projects:
    www.rclsoftware.org.uk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured