Help with Buffers!
-
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. -
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. -
You need to cast the pointers to correct type, e.g.
pBuffer1 = (PBYTE) malloc(INP_BUFFER_SIZE);
-
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. -
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.