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. std string/wstring and DLL

std string/wstring and DLL

Scheduled Pinned Locked Moved C / C++ / MFC
c++designquestion
3 Posts 2 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.
  • P Offline
    P Offline
    Paul Selormey
    wrote on last edited by
    #1

    The standard C++ provides string/wstring, an instantiation of basic_string<>. However, the Windows versions in VC++ does not seems to cooperate with DLLs when exporting classes containing string/wstring members. VC++ keeps giving the warning C4251. Is there anyway to use the standard strings in DLL as class members of exported classes? Currently, I am being forced to use them as function arguments/parameters and it is not always good for most design. Regards, Paul.

    U 1 Reply Last reply
    0
    • P Paul Selormey

      The standard C++ provides string/wstring, an instantiation of basic_string<>. However, the Windows versions in VC++ does not seems to cooperate with DLLs when exporting classes containing string/wstring members. VC++ keeps giving the warning C4251. Is there anyway to use the standard strings in DLL as class members of exported classes? Currently, I am being forced to use them as function arguments/parameters and it is not always good for most design. Regards, Paul.

      U Offline
      U Offline
      User 1052
      wrote on last edited by
      #2

      First question: What is error C4251, can you post the message that is with it? Second... I've never tried to do what your doing (at least I don't think so), but in COM we have to use BSTR ... not strings .... don't know if that will help at all.

      P 1 Reply Last reply
      0
      • U User 1052

        First question: What is error C4251, can you post the message that is with it? Second... I've never tried to do what your doing (at least I don't think so), but in COM we have to use BSTR ... not strings .... don't know if that will help at all.

        P Offline
        P Offline
        Paul Selormey
        wrote on last edited by
        #3

        Hello, Thanks for the response. Well, I never said error C4251, it is a warning! From the docs it is like this Compiler Warning (level 1) C4251 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' The specified base class was not declared with the __declspec(dllexport) keyword. A base class or structure must be declared with the __declspec(dllexport) keyword if a function in a derived class is to be exported. I am not building a COM interface, a simple non-MFC DLL. Regards, Paul.

        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