Cannot convert 'const void *' to 'const char *' in C++



 DEVELOP > c-Plus-Plus > Cannot convert 'const void *' to 'const char *' in C++

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 17 Aug 2006 08:13:32 AM
Object: Cannot convert 'const void *' to 'const char *' in C++
Hi,
I am using a API I downloaded from the internet programmed in C. I need
the function below which works with this api in my c++ file -
void StoreNoteCallback(void *context, int arglen, const void *args,
OSCTimeTag when,
NetworkReturnAddressPtr returnAddr)
{
const char *typeArgs = (const char *)args;
const float *floatArgs = &typeArgs[OSCPaddedStrlen(args)];
}
The problem is that the gives me the errors -
Cannot convert 'const void *' to 'const char *' in function
StoreNoteCallback
Type mismatch in parameter 's' (wanted 'const char *', got 'const void
*') in function StoreNoteCallback
Cannot convert 'const char *' to 'const float *' in function
StoreNoteCallbac
The above works in a c program. What's the problem and how do I fix it?
Thanks,
Barry.
.

User: "Heinz Ozwirk"

Title: Re: Cannot convert 'const void *' to 'const char *' in C++ 17 Aug 2006 10:23:08 AM
<bg_ie@yahoo.com> schrieb im Newsbeitrag
news:1155820412.467240.249740@b28g2000cwb.googlegroups.com...

Hi,

I am using a API I downloaded from the internet programmed in C. I need
the function below which works with this api in my c++ file -

void StoreNoteCallback(void *context, int arglen, const void *args,
OSCTimeTag when,
NetworkReturnAddressPtr returnAddr)
{
const char *typeArgs = (const char *)args;
const float *floatArgs = &typeArgs[OSCPaddedStrlen(args)];
}

The problem is that the gives me the errors -

Cannot convert 'const void *' to 'const char *' in function
StoreNoteCallback
Type mismatch in parameter 's' (wanted 'const char *', got 'const void
*') in function StoreNoteCallback
Cannot convert 'const char *' to 'const float *' in function
StoreNoteCallbac

What's the signature of OSCPaddedStrlen? Does it expect a const char* or a
const void*. Perhaps you should pass typeArgs to it instead of args.
Heinz
.

User: "Victor Bazarov"

Title: Re: Cannot convert 'const void *' to 'const char *' in C++ 17 Aug 2006 08:30:46 AM
wrote:

I am using a API I downloaded from the internet programmed in C. I
need the function below which works with this api in my c++ file -

void StoreNoteCallback(void *context, int arglen, const void *args,
OSCTimeTag when,
NetworkReturnAddressPtr returnAddr)
{
const char *typeArgs = (const char *)args;
const float *floatArgs = &typeArgs[OSCPaddedStrlen(args)];
}

The problem is that the gives me the errors -

Cannot convert 'const void *' to 'const char *' in function
StoreNoteCallback
Type mismatch in parameter 's' (wanted 'const char *', got 'const void
*') in function StoreNoteCallback

Which one is 's'? And you should be able to use 'static_cast' to fix
that...

Cannot convert 'const char *' to 'const float *' in function
StoreNoteCallbac

That can be remedied with 'reinterpret_cast'.


The above works in a c program. What's the problem and how do I fix
it?

Use 'reinterpret_cast':
const float *floatArgs = reinterpret_cast<const float*>(&type...
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.

User: "Frederick Gotham"

Title: Re: Cannot convert 'const void *' to 'const char *' in C++ 17 Aug 2006 12:49:02 PM

Cannot convert 'const void *' to 'const char *'

void *pv = 0;
char *pc;
pc = static_cast<char*>(pv);
--
Frederick Gotham
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER