|
From: rogFed28685 on 6 May 2008 11:28 Hi all, I was wondering if we could pass in an long value in an __int64 pointer variable and vice versa. So something like, someFunc(__ int64 *a) { do something; } int main() { long x; someFunc( ( __int64 *) &a) ; } Is it possible to send a long addreess value through an __int64 pointer variable? If not, how does one go about it? Any input is really appreciated...Im a newbie to pointers so if Q seems silly I apologize.
From: Giovanni Dicanio on 6 May 2008 11:39 <rogFed28685(a)gmail.com> ha scritto nel messaggio news:b26aeb38-b16d-4e6f-9031-2a4c08ef4400(a)k13g2000hse.googlegroups.com... > I was wondering if we could pass in an long value in an __int64 > pointer variable and vice versa. > > So something like, > > someFunc(__ int64 *a) > { Your code here means the following: " 'a' is a pointer to an __int64 variable " On 32 bits architectures machines, 'a' requires 4 bytes (32 bits), because it is a pointer, and every pointer on 32 bits machines is 32 bits = 4 bytes. > int main() > { > long x; > someFunc( ( __int64 *) &a) ; That is not very clear... Maybe do you mean passing ' &x ' (not &a) ? I think that you should adjust your code to make it compatible with someFunc function, e.g.: <code> // long variable long x; // Convery from long to __int64 __int64 a = static_cast< __int64 >( x ); // Pass pointer to a which is a __int64 someFunc( &a ); </code> > Any input is really appreciated...Im a newbie to pointers so if Q > seems silly I apologize. No question is "silly" here. We are a friendly community, and everyone of us was a beginner once upon a time :) Feel free to ask everything. HTH, Giovanni
From: David Wilkinson on 6 May 2008 11:43 rogFed28685(a)gmail.com wrote: > Hi all, > I was wondering if we could pass in an long value in an __int64 > pointer variable and vice versa. > > So something like, > > someFunc(__ int64 *a) > { > do something; > } > > int main() > { > long x; > someFunc( ( __int64 *) &a) ; > } > > Is it possible to send a long addreess value through an __int64 > pointer variable? If not, how does one go about it? > > Any input is really appreciated...Im a newbie to pointers so if Q > seems silly I apologize. rogFed: Well, you can do it (if you correct some errors in your code). But why would you want to? -- David Wilkinson Visual C++ MVP
From: Luke Alcatel on 6 May 2008 11:48 I assume you meant to use 'x' when you called someFunc from main rather than 'a'. Your code will fail if you dereference 'a' in someFunc and try to use the value or if you pass something back through the pointer. I'm surprised that is not obvious. It is one of the reasons that I think programmers miss a lot if they never coded in assembly. LA <rogFed28685(a)gmail.com> wrote in message news:b26aeb38-b16d-4e6f-9031-2a4c08ef4400(a)k13g2000hse.googlegroups.com... > Hi all, > I was wondering if we could pass in an long value in an __int64 > pointer variable and vice versa. > > So something like, > > someFunc(__ int64 *a) > { > do something; > } > > int main() > { > long x; > someFunc( ( __int64 *) &a) ; > } > > Is it possible to send a long addreess value through an __int64 > pointer variable? If not, how does one go about it? > > Any input is really appreciated...Im a newbie to pointers so if Q > seems silly I apologize.
From: Tom Serface on 6 May 2008 12:01 I don't think you can cast the pointer that way. You could simplify this by doing something like: void MyFunc(_int64 *a) { _int64 z = *a; } long x; x = 5; _int64 y = x; // This conversion done OK. MyFunc(&y); Tom <rogFed28685(a)gmail.com> wrote in message news:b26aeb38-b16d-4e6f-9031-2a4c08ef4400(a)k13g2000hse.googlegroups.com... > Hi all, > I was wondering if we could pass in an long value in an __int64 > pointer variable and vice versa. > > So something like, > > someFunc(__ int64 *a) > { > do something; > } > > int main() > { > long x; > someFunc( ( __int64 *) &a) ; > } > > Is it possible to send a long addreess value through an __int64 > pointer variable? If not, how does one go about it? > > Any input is really appreciated...Im a newbie to pointers so if Q > seems silly I apologize.
|
Next
|
Last
Pages: 1 2 Prev: Running Process in the Background Next: list of vc6 preprocessor switches? |