CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 1999
    Posts
    4

    Using VC++ generated DLLs in Borland C++ 5.0

    Hi All,

    I'm trying to create DLL in VC++ 6.0 with the follwing spec :

    extern "C"
    {
    int _pascal _export MyFunc(char *szSomeData);
    }

    Since VC++ environment doesn't support _pascal or _export keywords any more, I cannot compile my project.

    I'm using these keywords because one of our application was written in Borland C++ and I must use the above DLL with it.

    Brief : Can I create a DLL / LIB in VC++ that can be used in BC++ environment.

    Please do help me in this.

    Thanks in advance.


  2. #2
    Join Date
    Apr 1999
    Posts
    16

    Re: Using VC++ generated DLLs in Borland C++ 5.0

    Use the PASCAL and EXPORT keywords instead.


  3. #3
    Join Date
    May 1999
    Posts
    4

    Re: Using VC++ generated DLLs in Borland C++ 5.0

    Hi Cheng,

    Thank you.

    I tried to use PASCAL and EXPORT keywords, but that doesn't work either.
    Specifically, I can't use EXPORT keyword. Please suggest.

    Best regards,
    Rajesh


  4. #4
    Join Date
    Apr 1999
    Posts
    16

    Re: Using VC++ generated DLLs in Borland C++ 5.0

    I used these keywords as following:
    extern "C" BOOL PASCAL EXPORT DrawInit(int* nX,int* nY)
    {
    AFX_MANAGE_STATE(AfxGetStaticModuleState()); //if you use MFC
    }
    Add the function name to the EXPORTS section of the .def file.
    It works well.I don't know what your matter really is, so I can't give you any more valuable
    ideas.


  5. #5
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Using VC++ generated DLLs in Borland C++ 5.0

    Try this :

    extern "C"
    {
    int _stdcall __declspec(dllexport) MyFunc(char *szSomeData);
    }



  6. #6
    Join Date
    May 1999
    Location
    Oregon, USA
    Posts
    302

    Re: Using VC++ generated DLLs in Borland C++ 5.0

    Try this :

    extern "C"
    {
    int _stdcall __declspec(dllexport) MyFunc(char *szSomeData);
    }

    This will export as _MyFunc@4 unless you use a .def file
    If you use a header file to give the appropriate prototype
    you shouldn't have a problem.




  7. #7
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Using VC++ generated DLLs in Borland C++ 5.0

    You are not defining the exported function correctly. The _export keyword is not used in a 32-bit environment. That's why VC++ ignores it.

    If you are building a 32-bit DLL, there should be no problem in defining the functions as this:

    #ifdef DLL
    #define FUNCDEF __declspec( dllexport ) __stdcall
    #else
    #define FUNCDEF __stdcall
    #endif

    extern "C" {
    BOOL FUNCDEF MyFunc(int);
    }

    This works in both Borland and Microsoft. Just define the DLL symbol if you are compiling the DLL.

    Regards,

    Paul McKenzie


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