Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Passing CString between DLLs

Passing CString between DLLs

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studioquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    uusheikh
    wrote on last edited by
    #1

    I have a DLL created in Visual Studio 2005, and going to use it in Visual Studio 2008. The function in the DLL takes CString as a parameter. Is it safe to send CString from VS08 to VS05/VC6 DLL? I think different versions of VC++ will have different internal implementation of CString and it would not be safe. Whats the best way?

    M 1 Reply Last reply
    0
    • U uusheikh

      I have a DLL created in Visual Studio 2005, and going to use it in Visual Studio 2008. The function in the DLL takes CString as a parameter. Is it safe to send CString from VS08 to VS05/VC6 DLL? I think different versions of VC++ will have different internal implementation of CString and it would not be safe. Whats the best way?

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      The VS2005 and VS2008 sides are going to use different CRT libraries so passing anything but const pointers isn't going to be safe. Also, as you mentioned, the CString implementations may be different so passing CStrings isn't safe. Passing LPCSTRs is safest - let the receiver make a local CString copy from the passed pointer if necessary. Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      U 1 Reply Last reply
      0
      • M Mark Salsbery

        The VS2005 and VS2008 sides are going to use different CRT libraries so passing anything but const pointers isn't going to be safe. Also, as you mentioned, the CString implementations may be different so passing CStrings isn't safe. Passing LPCSTRs is safest - let the receiver make a local CString copy from the passed pointer if necessary. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        U Offline
        U Offline
        uusheikh
        wrote on last edited by
        #3

        What about sending std::string? Is it also NOT safe?

        B M 2 Replies Last reply
        0
        • U uusheikh

          What about sending std::string? Is it also NOT safe?

          B Offline
          B Offline
          Bram van Kampen
          wrote on last edited by
          #4

          What about sending it as a LPCSTR :)

          Bram van Kampen

          U 1 Reply Last reply
          0
          • B Bram van Kampen

            What about sending it as a LPCSTR :)

            Bram van Kampen

            U Offline
            U Offline
            uusheikh
            wrote on last edited by
            #5

            :) Maybe I should..

            1 Reply Last reply
            0
            • U uusheikh

              What about sending std::string? Is it also NOT safe?

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              uus831 wrote:

              What about sending std::string?

              Same as CStringT :)

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups