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. Conversion from VC6 to VC8

Conversion from VC6 to VC8

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++comgraphicsdiscussion
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.
  • T Offline
    T Offline
    ThatsAlok
    wrote on last edited by
    #1

    While converting some of my old dll which is currently compiled in VC6 and is also running successfully. VC2005 compile is throwing compiler error for this piece of code :-

    string MyReturn()
    {
    return string(reinterpret_cast(vec.begin()), vec.size());
    }

    here return type string is STL::string and vec is stl::vector of type unsigned char and i am receiving following error :-

    error C2440: 'reinterpret_cast' : cannot convert from 'std::_Vector_const_iterator<_Ty,_Alloc>'
    to 'const char *'
    with
    [
    _Ty=unsigned char,
    _Alloc=std::allocator
    ]
    Conversion requires a constructor or user-defined-conversion operator,
    which can't be used by const_cast or reinterpret_cast

    Does anyone know or can give direction to solve above problem, i have tried many way myself, was successfull in using _myfirst member of vector to resolve the problem, but it started giving some other problem. Thanks in advance

    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
    Never mind - my own stupidity is the source of every "problem" - Mixture

    cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

    _ E 2 Replies Last reply
    0
    • T ThatsAlok

      While converting some of my old dll which is currently compiled in VC6 and is also running successfully. VC2005 compile is throwing compiler error for this piece of code :-

      string MyReturn()
      {
      return string(reinterpret_cast(vec.begin()), vec.size());
      }

      here return type string is STL::string and vec is stl::vector of type unsigned char and i am receiving following error :-

      error C2440: 'reinterpret_cast' : cannot convert from 'std::_Vector_const_iterator<_Ty,_Alloc>'
      to 'const char *'
      with
      [
      _Ty=unsigned char,
      _Alloc=std::allocator
      ]
      Conversion requires a constructor or user-defined-conversion operator,
      which can't be used by const_cast or reinterpret_cast

      Does anyone know or can give direction to solve above problem, i have tried many way myself, was successfull in using _myfirst member of vector to resolve the problem, but it started giving some other problem. Thanks in advance

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
      Never mind - my own stupidity is the source of every "problem" - Mixture

      cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Use another string constructor.

      return string(vec.begin(), vec.end());

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      T 1 Reply Last reply
      0
      • _ _Superman_

        Use another string constructor.

        return string(vec.begin(), vec.end());

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        Nope not working :-

        error C2665: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string' : none of the 13 overloads could convert all the argument types

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
        Never mind - my own stupidity is the source of every "problem" - Mixture

        cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

        _ 1 Reply Last reply
        0
        • T ThatsAlok

          While converting some of my old dll which is currently compiled in VC6 and is also running successfully. VC2005 compile is throwing compiler error for this piece of code :-

          string MyReturn()
          {
          return string(reinterpret_cast(vec.begin()), vec.size());
          }

          here return type string is STL::string and vec is stl::vector of type unsigned char and i am receiving following error :-

          error C2440: 'reinterpret_cast' : cannot convert from 'std::_Vector_const_iterator<_Ty,_Alloc>'
          to 'const char *'
          with
          [
          _Ty=unsigned char,
          _Alloc=std::allocator
          ]
          Conversion requires a constructor or user-defined-conversion operator,
          which can't be used by const_cast or reinterpret_cast

          Does anyone know or can give direction to solve above problem, i have tried many way myself, was successfull in using _myfirst member of vector to resolve the problem, but it started giving some other problem. Thanks in advance

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
          Never mind - my own stupidity is the source of every "problem" - Mixture

          cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

          E Offline
          E Offline
          Emilio Garavaglia
          wrote on last edited by
          #4

          It seems the vector holds unsigned chars while the string holds char. Try:

          string((const char*)&vect[0], vect.size());

          2 bugs found. > recompile ... 65534 bugs found. :doh:

          1 Reply Last reply
          0
          • T ThatsAlok

            Nope not working :-

            error C2665: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string' : none of the 13 overloads could convert all the argument types

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
            Never mind - my own stupidity is the source of every "problem" - Mixture

            cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #5

            I tried this first before replying to you and it is working fine. I used Visual Studio 2008 Here is what I tried -

            vector<unsigned char> vec;
            vec.push_back('A');
            vec.push_back('B');
            vec.push_back('C');

            string s(vec.begin(), vec.end());

            «_Superman_» I love work. It gives me something to do between weekends.
            Microsoft MVP (Visual C++)

            T 1 Reply Last reply
            0
            • _ _Superman_

              I tried this first before replying to you and it is working fine. I used Visual Studio 2008 Here is what I tried -

              vector<unsigned char> vec;
              vec.push_back('A');
              vec.push_back('B');
              vec.push_back('C');

              string s(vec.begin(), vec.end());

              «_Superman_» I love work. It gives me something to do between weekends.
              Microsoft MVP (Visual C++)

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              «_Superman_» wrote:

              I used Visual Studio 2008

              Apology, I am using VC8 Aka Visual Studio 2005

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
              Never mind - my own stupidity is the source of every "problem" - Mixture

              cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

              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