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. Help with Buffers!

Help with Buffers!

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++visual-studioperformance
5 Posts 4 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
    Paddy
    wrote on last edited by
    #1

    Hi, I hope someone can solve this problem for me please! I have a program in C for recording raw audio samples from the souncard into a buffer in the memory. It compiles and runs perfecty in visual studio. However when I copy the code into a VC++ program it complains about all the memory commands like malloc, realloc ect. Maybe I have to include some .lib file?? Here is some of the code that is causing the problem: static PBYTE pBuffer1, pSaveBuffer; pBuffer1 = malloc (INP_BUFFER_SIZE) ; error C2440: '=' : cannot convert from 'void *' to 'PBYTE' pWaveHdr1->lpData = pBuffer1 ; error C2440: '=' : cannot convert from 'PBYTE' to 'LPSTR' pSaveBuffer = realloc (pSaveBuffer, 1) ; error C2440: '=' : cannot convert from 'void *' to 'PBYTE' Any ideas? Thanks in advance, Paddy.

    M A S 3 Replies Last reply
    0
    • P Paddy

      Hi, I hope someone can solve this problem for me please! I have a program in C for recording raw audio samples from the souncard into a buffer in the memory. It compiles and runs perfecty in visual studio. However when I copy the code into a VC++ program it complains about all the memory commands like malloc, realloc ect. Maybe I have to include some .lib file?? Here is some of the code that is causing the problem: static PBYTE pBuffer1, pSaveBuffer; pBuffer1 = malloc (INP_BUFFER_SIZE) ; error C2440: '=' : cannot convert from 'void *' to 'PBYTE' pWaveHdr1->lpData = pBuffer1 ; error C2440: '=' : cannot convert from 'PBYTE' to 'LPSTR' pSaveBuffer = realloc (pSaveBuffer, 1) ; error C2440: '=' : cannot convert from 'void *' to 'PBYTE' Any ideas? Thanks in advance, Paddy.

      M Offline
      M Offline
      markkuk
      wrote on last edited by
      #2

      You need to cast the pointers to correct type, e.g.

      pBuffer1 = (PBYTE) malloc(INP_BUFFER_SIZE);

      P 1 Reply Last reply
      0
      • M markkuk

        You need to cast the pointers to correct type, e.g.

        pBuffer1 = (PBYTE) malloc(INP_BUFFER_SIZE);

        P Offline
        P Offline
        Paddy
        wrote on last edited by
        #3

        Thanks problem solved!

        1 Reply Last reply
        0
        • P Paddy

          Hi, I hope someone can solve this problem for me please! I have a program in C for recording raw audio samples from the souncard into a buffer in the memory. It compiles and runs perfecty in visual studio. However when I copy the code into a VC++ program it complains about all the memory commands like malloc, realloc ect. Maybe I have to include some .lib file?? Here is some of the code that is causing the problem: static PBYTE pBuffer1, pSaveBuffer; pBuffer1 = malloc (INP_BUFFER_SIZE) ; error C2440: '=' : cannot convert from 'void *' to 'PBYTE' pWaveHdr1->lpData = pBuffer1 ; error C2440: '=' : cannot convert from 'PBYTE' to 'LPSTR' pSaveBuffer = realloc (pSaveBuffer, 1) ; error C2440: '=' : cannot convert from 'void *' to 'PBYTE' Any ideas? Thanks in advance, Paddy.

          S Offline
          S Offline
          slt
          wrote on last edited by
          #4

          I think you need to use casting - as follows: pBuffer1 = (PBYTE) malloc (INP_BUFFER_SIZE) ; pWaveHdr1->lpData = (LPSTR) pBuffer1 ; pSaveBuffer = (PBYTE) realloc (pSaveBuffer, 1) ; That should solve the compiler errors. Scott

          1 Reply Last reply
          0
          • P Paddy

            Hi, I hope someone can solve this problem for me please! I have a program in C for recording raw audio samples from the souncard into a buffer in the memory. It compiles and runs perfecty in visual studio. However when I copy the code into a VC++ program it complains about all the memory commands like malloc, realloc ect. Maybe I have to include some .lib file?? Here is some of the code that is causing the problem: static PBYTE pBuffer1, pSaveBuffer; pBuffer1 = malloc (INP_BUFFER_SIZE) ; error C2440: '=' : cannot convert from 'void *' to 'PBYTE' pWaveHdr1->lpData = pBuffer1 ; error C2440: '=' : cannot convert from 'PBYTE' to 'LPSTR' pSaveBuffer = realloc (pSaveBuffer, 1) ; error C2440: '=' : cannot convert from 'void *' to 'PBYTE' Any ideas? Thanks in advance, Paddy.

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            I think you need to use casting - as follows: pBuffer1 = (PBYTE) malloc (INP_BUFFER_SIZE) ; pWaveHdr1->lpData = (LPSTR) pBuffer1 ; pSaveBuffer = (PBYTE) realloc (pSaveBuffer, 1) ; That should solve the compiler errors. Scott

            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