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. error C2664 with InterlockedExchangePointer

error C2664 with InterlockedExchangePointer

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 1 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.
  • B Offline
    B Offline
    Boaz V
    wrote on last edited by
    #1

    I'm moving from VC6 to VC2003 and from multi-byte to Unicode. After fixing all the errors related to unicode, i ended with an error i can not resolve. ************ error C2664: 'InterlockedExchangePointer' : cannot convert parameter 1 from 'T ** ' to 'void ** ' with [ T=MyClass ] Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast ******************** The code is: *************** MyClass * mQ_waiting_for_write; InterlockedExchangePointer(&mQ_waiting_for_write, NULL); ************** Any ideas what is the problem?

    B 1 Reply Last reply
    0
    • B Boaz V

      I'm moving from VC6 to VC2003 and from multi-byte to Unicode. After fixing all the errors related to unicode, i ended with an error i can not resolve. ************ error C2664: 'InterlockedExchangePointer' : cannot convert parameter 1 from 'T ** ' to 'void ** ' with [ T=MyClass ] Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast ******************** The code is: *************** MyClass * mQ_waiting_for_write; InterlockedExchangePointer(&mQ_waiting_for_write, NULL); ************** Any ideas what is the problem?

      B Offline
      B Offline
      Boaz V
      wrote on last edited by
      #2

      This is the right way to do it: void** arg = static_cast(static_cast(&mQ_waiting_for_write)); InterlockedExchangePointer(arg, new_Q); or shorter: InterlockedExchangePointer((void**)&mQ_waiting_for_write, new_Q);

      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