where "fake_ptr" contained the address of some variable of type "someType" and it was passed to "function". I had to do this because I couldn't pass directly a pointer of "someType" type to "function". And in C it worked very well.

But now I tried to do the same in C++ but the compiler got this error:

" invalid conversion from 'int' to 'someType*' "

So I would like to know if there is some way to solve this without pass directly a "someType" pointer to "function" but a int variable by containing the address of some "someType" variable in C++ ??

I hope you have understand me... sorry for my bad english :(

02-18-2006

Magos

reinterpret_cast

02-19-2006

Salem

How about telling us what you're trying to do?
Because a newbie needing to use reinterpret_cast in C++ is a sure sign of something going badly wrong.

02-19-2006

CornedBee

And passing an address in an int is a sure way not to have 64-bit compatibility.

02-19-2006

OnionKnight

How can your compiler not allow you to pass a someType pointer to your function? That sounds very strange to me. To check if you've done things correctly, did you declare the formal parameter as illustrated in red below?

Code:

int function(someType* fake_ptr)
{
someType *pointer = fake_ptr;

/* More code here */

return some;
}

02-19-2006

CornedBee

I suspect it's a callback with an established prototype. Happens in Win32 programming all the time.

02-20-2006

nmxnmx

Hi again, well I can't pass a someType pointer but not for my compiler, but I'm need to link C++ code to a software named LabView, in that software you can call some dll's made in any language (like C/C++), but when you configure it, it only allows some basic type of parameters (int, float, char*) but not some complex parameter or others types that the basics (and others from it owns)..

That's why in complex data I passed addresses to pointer of "someType" in int variables in C but it doesn't work in C++

So I hope you can understand me and again sorry for my bad english, and thanks in advanced...