Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how to convert void* to struct* in visual c++

hanxhanx Member Posts: 5
I am trying to use MAD library (libmad) which is a decoding library for mp3 in visual c++. The library is in visual c++ project and it opens and compiles as "libmad.lib". Then i tried to use this library as a simple decoding console program just like "minimad.c", which is in POSIX form" to my own Visual C++ console program.

Then I get error for conversion. The error no. is error C2440. I goggled this error number and i came to conclusion that void data type cannot be converted to any other type in Visual C++ as it is possible in GNU Compiler in Linux.

So any one can please tell me a way to convert void* to stuct*. I used type casting in some way, it solved the error of conversion of char* but i am not able to convert void* to struct*. The void* is mostly used in the libmad library. So it is unavoidable. Please Help me..

Here are the links:
libmad or MAD = http://www.underbit.com/products/mad/

Code:

[code]
static enum mad_flow input(void *data, struct mad_stream *stream)
{


struct buffer *buffer = data; //Compiler points error:2440 here

if (!buffer->length)
return MAD_FLOW_STOP;

mad_stream_buffer(stream, buffer->start, buffer->length);
buffer->length = 0;

return MAD_FLOW_CONTINUE;
}
[/code]

Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : [code]:
    : static enum mad_flow input(void *data, struct mad_stream *stream)
    : {
    :
    :
    : struct buffer *buffer = [color=Red](struct buffer *)[/color] data; //Compiler points error:2440 here
    :
    : if (!buffer->length)
    : return MAD_FLOW_STOP;
    :
    : mad_stream_buffer(stream, buffer->start, buffer->length);
    : buffer->length = 0;
    :
    : return MAD_FLOW_CONTINUE;
    : }
    : [/code]:
    :
  • hanxhanx Member Posts: 5
    thnx AsmGuru62 ... that worked very well but now i have other error but that i will manage.. thank you once again..
  • hanxhanx Member Posts: 5
    This post has been deleted.
Sign In or Register to comment.