472,975 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,975 software developers and data experts.

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.

Aug 17 '06 #1
3 13695
bg***@yahoo.com 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
Aug 17 '06 #2
<bg***@yahoo.comschrieb im Newsbeitrag
news:11**********************@b28g2000cwb.googlegr oups.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

Aug 17 '06 #3
Cannot convert 'const void *' to 'const char *'

void *pv = 0;

char *pc;

pc = static_cast<char*>(pv);

--

Frederick Gotham
Aug 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brad Moore | last post by:
Hey all, I'm getting the following compiler error from my code. I was wondering if anyone could help me understand the concept behind it (I actually did try and compile this degenerate...
6
by: John Smith | last post by:
What's wrong with the use of atoi in the following code? Why do I get the error message: 'atoi' : cannot convert parameter 1 from 'char' to 'const char *' char cBuffer; void...
1
by: Steven Woody | last post by:
somewhere in my code, char* rtnStrs = { "ok", "error", NULL }; foo( rtnStrs ); here, foo was decleared as 'void foo( const char * rtnStrs ). but the gcc compiler will report ' can not...
65
by: kyle.tk | last post by:
I am trying to write a function to convert an ipv4 address that is held in the string char *ip to its long value equivalent. Here is what I have right now, but I can't seem to get it to work. ...
18
by: ReaperUnreal | last post by:
I've got a strange problem here. I need to take a value that I have written down on a sticky-note here, and find what's at that address in current memory. I've tried the following: void *value =...
10
by: sposes | last post by:
Im very much a newbie but perhaps somehone can help me. Ive been searching for a way to convert a std::string to a unsigned char* The situation is I have a function that wants a unsigned char*...
1
by: asenthil | last post by:
Hai this is senthil... I had tried to write a string which fetched from a database. into a file... when i tried to compile the solution the following error occurs like this error C2664:...
2
by: nassim.bouayad.agha | last post by:
Hello, here is a code snippet showning my problem : template<typename _K> class TClass1 { public: void Process(const _K& arg) const {
1
codexparse
by: codexparse | last post by:
I am writing a browser program in C++ Builder 6 that loads a web page using the following code: void __fastcall TForm1::ToolButton1Click(TObject *Sender) { wchar_t buff; ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.