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. VC6.0 compiler error C2664 while using GUID

VC6.0 compiler error C2664 while using GUID

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionjsontutorial
6 Posts 5 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.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    I am in over my head again. I am getting error C2664 and I did read the Tech note ( something about ANSI improvement) about it and frankly I just do not understand what is the problem and how to fix it in VC6.0. Do I have to redefine the GUID_DEVCLASS_COMPUTER? The parameter GUID is defined in both functions as “const GUID*” The API fails with this error C2664 and C_GetClassImgIndex compiles OK error C2664: 'SetupDiGetClassImageIndex' : cannot convert parameter 2 from 'const struct _GUID *' to 'struct _GUID *' Conversion loses qualifiers Fails b = SetupDiGetClassImageIndex(&m_imgList, &GUID_DEVCLASS_COMPUTER, &nRootImg); OK int n = C_GetClassImgIndex(&GUID_DEVCLASS_COMPUTER); Any help would be greatly appreciated. Cheers Vaclav

    L P A 3 Replies Last reply
    0
    • V Vaclav_

      I am in over my head again. I am getting error C2664 and I did read the Tech note ( something about ANSI improvement) about it and frankly I just do not understand what is the problem and how to fix it in VC6.0. Do I have to redefine the GUID_DEVCLASS_COMPUTER? The parameter GUID is defined in both functions as “const GUID*” The API fails with this error C2664 and C_GetClassImgIndex compiles OK error C2664: 'SetupDiGetClassImageIndex' : cannot convert parameter 2 from 'const struct _GUID *' to 'struct _GUID *' Conversion loses qualifiers Fails b = SetupDiGetClassImageIndex(&m_imgList, &GUID_DEVCLASS_COMPUTER, &nRootImg); OK int n = C_GetClassImgIndex(&GUID_DEVCLASS_COMPUTER); Any help would be greatly appreciated. Cheers Vaclav

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Vaclav_Sal wrote:

      The API fails with this error C2664

      You are not using the API, this is a compiler error.

      Vaclav_Sal wrote:

      cannot convert parameter 2 from 'const struct _GUID *' to 'struct _GUID *'

      You are passing a const parameter to a function that does not expect one. Use const_cast[^] to remove it. But be sure you understand the potential consequences.

      One of these days I'm going to think of a really clever signature.

      V 1 Reply Last reply
      0
      • L Lost User

        Vaclav_Sal wrote:

        The API fails with this error C2664

        You are not using the API, this is a compiler error.

        Vaclav_Sal wrote:

        cannot convert parameter 2 from 'const struct _GUID *' to 'struct _GUID *'

        You are passing a const parameter to a function that does not expect one. Use const_cast[^] to remove it. But be sure you understand the potential consequences.

        One of these days I'm going to think of a really clever signature.

        V Offline
        V Offline
        Vaclav_
        wrote on last edited by
        #3

        Richard , I do not follow your explanation. In this MSDN doc the second parameter is defined as const GUID*. Am I using wrong version ot the Setupapi.h? PS Did you read the title? I did say compiler error.I do appreciate your help, but growing little tired of your sideline remarks,that's all. http://msdn.microsoft.com/en-us/library/windows/hardware/ff551074(v=vs.85).aspx BOOL SetupDiGetClassImageIndex( _In_   PSP_CLASSIMAGELIST_DATA ClassImageListData, _In_   const GUID *ClassGuid, _Out_  PINT ImageIndex );

        J 1 Reply Last reply
        0
        • V Vaclav_

          Richard , I do not follow your explanation. In this MSDN doc the second parameter is defined as const GUID*. Am I using wrong version ot the Setupapi.h? PS Did you read the title? I did say compiler error.I do appreciate your help, but growing little tired of your sideline remarks,that's all. http://msdn.microsoft.com/en-us/library/windows/hardware/ff551074(v=vs.85).aspx BOOL SetupDiGetClassImageIndex( _In_   PSP_CLASSIMAGELIST_DATA ClassImageListData, _In_   const GUID *ClassGuid, _Out_  PINT ImageIndex );

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          Vaclav_Sal wrote:

          _In_   const GUID *ClassGuid,

          The pointer is a constant, not the structure.

          1 Reply Last reply
          0
          • V Vaclav_

            I am in over my head again. I am getting error C2664 and I did read the Tech note ( something about ANSI improvement) about it and frankly I just do not understand what is the problem and how to fix it in VC6.0. Do I have to redefine the GUID_DEVCLASS_COMPUTER? The parameter GUID is defined in both functions as “const GUID*” The API fails with this error C2664 and C_GetClassImgIndex compiles OK error C2664: 'SetupDiGetClassImageIndex' : cannot convert parameter 2 from 'const struct _GUID *' to 'struct _GUID *' Conversion loses qualifiers Fails b = SetupDiGetClassImageIndex(&m_imgList, &GUID_DEVCLASS_COMPUTER, &nRootImg); OK int n = C_GetClassImgIndex(&GUID_DEVCLASS_COMPUTER); Any help would be greatly appreciated. Cheers Vaclav

            P Offline
            P Offline
            PecuniousPete
            wrote on last edited by
            #5

            Oh come on man, it is the C language. If the compiler bitches just cast it out. YOU are in control. YO are the master! :)

            1 Reply Last reply
            0
            • V Vaclav_

              I am in over my head again. I am getting error C2664 and I did read the Tech note ( something about ANSI improvement) about it and frankly I just do not understand what is the problem and how to fix it in VC6.0. Do I have to redefine the GUID_DEVCLASS_COMPUTER? The parameter GUID is defined in both functions as “const GUID*” The API fails with this error C2664 and C_GetClassImgIndex compiles OK error C2664: 'SetupDiGetClassImageIndex' : cannot convert parameter 2 from 'const struct _GUID *' to 'struct _GUID *' Conversion loses qualifiers Fails b = SetupDiGetClassImageIndex(&m_imgList, &GUID_DEVCLASS_COMPUTER, &nRootImg); OK int n = C_GetClassImgIndex(&GUID_DEVCLASS_COMPUTER); Any help would be greatly appreciated. Cheers Vaclav

              A Offline
              A Offline
              Arild Fiskum
              wrote on last edited by
              #6

              Have you tried something like this: GUID tmp(GUID_DEVCLASS_COMPUTER); b = SetupDiGetClassImageIndex(&m_imgList, &tmp, &nRootImg);

              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