CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2002
    Location
    Seattle Area, WA
    Posts
    241

    What type of project for DLL?

    OK, it seems my task is changing here at work.

    We have old code that is written in Visual Studio 6 (C++ code, lots of MFC). I need to take a part of it out and make it in its own DLL.

    Here's the main issue (as I've never worked with VS 6 playing nicely with VS 8 before).

    The main area the code is in is a DLL in VS 6.
    The main EXE is a windows application in VS6.
    I need to take a portion of the main DLL and put it in a separate DLL which will be done in VS 8 (VS 2005).

    So the VS C++ 6.0 code needs to be able to use this new DLL written in VS C++ 8.0. I assume this must be possible of VS.NET would have broken everything. So, what type of project should I choose to create this new DLL in VS 8?

    MFC DLL?

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: What type of project for DLL?

    If you build the DLL with VC9 and use it in VC6, then you are likely to run into problems, because you cannot mix CRT versions without limitations. When you allocate memory with new or delete with a CRT version than you must release it with the same CRT (this also includes allocations done behind the scene). Then the CRT defined structures may have different layouts between different versions, so if you cannot pass objects with different layouts between modules.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Jul 2002
    Location
    Seattle Area, WA
    Posts
    241

    Re: What type of project for DLL?

    I was afraid this might be the answer. What is CRT that you are talking about? Can you point me to any references so I can show others I work with?

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: What type of project for DLL?

    C and C++ Runtime. It's composed of msvcrXX.dll, msvcpXX.dll and msvcmXX.dll.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  5. #5
    Join Date
    Jul 2002
    Location
    Seattle Area, WA
    Posts
    241

    Re: What type of project for DLL?

    Ok....I guess I need to find out what's possible and what is not.

    Just before I started this thread, I started a small 'proof of concept' project (two actually). I created a simple VC++ 8.0 MFC DLL which had a simple function to accept an integer input and print a hello message (AfxMsgbox) with the integer sent in.

    I wrote an EXE calling program on the VC++ 6.0 side to call that function.

    It is working.

    If what you said before is true, it shouldn't have worked, right? I'm a bit confused.

  6. #6
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: What type of project for DLL?

    No. That should work. I told that you must delete from the same CRT version you allocated dynamic memory. As for structures with different layouts, that doesn't refer to ints.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  7. #7
    Join Date
    Jul 2002
    Location
    Seattle Area, WA
    Posts
    241

    Re: What type of project for DLL?

    Quote Originally Posted by cilu View Post
    No. That should work. I told that you must delete from the same CRT version you allocated dynamic memory. As for structures with different layouts, that doesn't refer to ints.
    Are you saying then, my only main issue to really worry about is dynamically allocated memory that is passed between them? If so, I can probably work around that as I don't think it is done thaaat much any way.

    However, what about regular allocated memory? Will that possibly be an issue? I believe there is a lot of instantiating a class on the calling side (which will be the VC++ 6 side) and then calling a function in the DLL with that object pointer as an argument. That sounds like it could be an issue if the CRT has different sizes for any data types in that class.

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