Thread: C->Cdll->C#dll under VS2008

  1. #1
    Registered User
    Join Date
    Oct 2008

    C->Cdll->C#dll under VS2008

    Hello experts !
    I try to implement the following calling chain (for history reasons, thus is a given):
    C (.c file, main) -> calling C(.c file dll) -> calling C#(cs. file dll). All thatís under VS2008. Of course, between the C dll and the C# dll I have implemented a COM model, works fine; between the C main and the C dll is basic (I use a .def file for the C dll). The compiler is C++ for the C projects.
    Now, with the C-C dll working ok, I try to insert #import <the C# tlb library> into the C dll to start building the COM to the C#. The build of the C dll says error 2773, i.e. I need to use the C++ compiler (which is the case, and referenced into the projectís properties). As soon as I change the C dll source file type to .cpp the build goes through, but not anymore the one of the C main (error LNK 2019, doesnít find the C dll function). All starts from the 2773 error which is not in accordance with the projectís settings. Any hints?

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    To call from C functions compiled with C++ you need in the function prototypes add
    extern "C"

    you could wrap the contents of the h file that contains the dll-interface used by the main
    inside the following code
    #ifdef __cplusplus
    extern "C" {
    /* here go all the function prototypes that should be called from the pure C */
    #ifdef __cplusplus
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    Ė David J. Wheeler

  3. #3
    Registered User
    Join Date
    Oct 2008
    Thanks Vart! I put it into the .h file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Configuring VS2008 C++ to C
    By Akkernight in forum C Programming
    Replies: 8
    Last Post: 02-28-2009, 04:17 AM
  2. MASM In VS2008
    By valaris in forum Tech Board
    Replies: 1
    Last Post: 01-13-2009, 09:11 PM
  3. Need VS2008 Verification
    By rags_to_riches in forum C++ Programming
    Replies: 7
    Last Post: 10-14-2008, 04:51 AM
  4. Does VS2008 have anything like Pythons IDLE?
    By atomsmasher442 in forum C# Programming
    Replies: 1
    Last Post: 07-26-2008, 04:37 AM
  5. nmake won't work in vs2008
    By inhahe in forum Windows Programming
    Replies: 2
    Last Post: 05-16-2008, 03:58 AM