f



pointer to a pointer

My situation:

I have a function that takes a pointer to an FSref as an argument. In 
the body of the function is a function call that also takes a pointer to 
an FSRef. I need to pass my original FSRef, but since I have only a 
pointer to it, I am assuming I need to dereference it twice when I call 
the second function. However, using something like &&myFSRef in the 
second function doesn't work.

Can anyone tell me the proper way to do this?

Thanks.
0
Steven
1/15/2005 3:24:57 PM
comp.mac.codewarrior 2568 articles. 0 followers. ja7789 (3) is leader. Post Follow

3 Replies
759 Views

Similar Articles

[PageSpeed] 13

In article <1105802448.cd52b3255e6c95476ce23f7be215a6a3@teranews>,
 Steven Daedelus <sdaedelus@ira.gov> wrote:

> I have a function that takes a pointer to an FSref as an argument. In 
> the body of the function is a function call that also takes a pointer to 
> an FSRef. I need to pass my original FSRef, but since I have only a 
> pointer to it, I am assuming I need to dereference it twice when I call 
> the second function. However, using something like &&myFSRef in the 
> second function doesn't work.

&&myFSRef could never parse, since:
a.) "&&" is a token that would be picked up by the parser to mean 
logical, short-circuiting "and". Note: "and" is a keyword in the C++ 
language that means itself, so I prefer to use it, not "&&".

b.) If the parser DID tokenize it correctly, the compiler would still 
give you an error message, since you are asking for the address of an 
address, but an address is just a number, it has no address any more 
than you can ask for the address of "3". An address is not an "l-value" 
where "l-value" is the term for the kind of value that can appear on the 
left side of an assignment statement. "foo=2;" is legal because foo is 
an l-value. "2=foo;" is not legal because 2 is not an l-value. "&foo" is 
legal, "& & foo" is not.

Your question contains its own answer:

FSRef originalRef;

void Func1(FSRef *fsRefp){

//... does something with it here.

}

void Func2(FSRef *fsRefp){
   Func1(&originalRef); // Note 1 below
   Func1(fsRefp);
}

//         "In the body of the function is a function call"
// Note 1: "that also takes a pointer to an FSRef"

Since it takes what you've already got, you just pass it.

Func2(&originalRef);

-- 
David Phillip Oster
0
David
1/15/2005 3:58:42 PM

David Phillip Oster wrote:
> In article <1105802448.cd52b3255e6c95476ce23f7be215a6a3@teranews>,
>  Steven Daedelus <sdaedelus@ira.gov> wrote:
> 
> 
>>I have a function that takes a pointer to an FSref as an argument. In 
>>the body of the function is a function call that also takes a pointer to 
>>an FSRef. I need to pass my original FSRef, but since I have only a 
>>pointer to it, I am assuming I need to dereference it twice when I call 
>>the second function. However, using something like &&myFSRef in the 
>>second function doesn't work.

Or, if this is what you meant:

void Func1( FSRef* inRef ) {
	Func2( *inRef );
}

void Func2( FSRef ref ) {
	
}


> 

> 
> &&myFSRef could never parse, since:
> a.) "&&" is a token that would be picked up by the parser to mean 
> logical, short-circuiting "and". Note: "and" is a keyword in the C++ 
> language that means itself, so I prefer to use it, not "&&".
> 
> b.) If the parser DID tokenize it correctly, the compiler would still 
> give you an error message, since you are asking for the address of an 
> address, but an address is just a number, it has no address any more 
> than you can ask for the address of "3". An address is not an "l-value" 
> where "l-value" is the term for the kind of value that can appear on the 
> left side of an assignment statement. "foo=2;" is legal because foo is 
> an l-value. "2=foo;" is not legal because 2 is not an l-value. "&foo" is 
> legal, "& & foo" is not.
> 
> Your question contains its own answer:
> 
> FSRef originalRef;
> 
> void Func1(FSRef *fsRefp){
> 
> //... does something with it here.
> 
> }
> 
> void Func2(FSRef *fsRefp){
>    Func1(&originalRef); // Note 1 below
>    Func1(fsRefp);
> }
> 
> //         "In the body of the function is a function call"
> // Note 1: "that also takes a pointer to an FSRef"
> 
> Since it takes what you've already got, you just pass it.
> 
> Func2(&originalRef);
> 
0
Sexy27
1/15/2005 4:23:28 PM
In article 
<oster-BAE656.07583215012005@newssvr21-ext.news.prodigy.com>,
 David Phillip Oster <oster@ieee.org> wrote:

> In article <1105802448.cd52b3255e6c95476ce23f7be215a6a3@teranews>,
>  Steven Daedelus <sdaedelus@ira.gov> wrote:
> 
> > I have a function that takes a pointer to an FSref as an argument. In 
> > the body of the function is a function call that also takes a pointer to 
> > an FSRef. I need to pass my original FSRef, but since I have only a 
> > pointer to it, I am assuming I need to dereference it twice when I call 
> > the second function. However, using something like &&myFSRef in the 
> > second function doesn't work.
> 
> &&myFSRef could never parse, since:
> a.) "&&" is a token that would be picked up by the parser to mean 
> logical, short-circuiting "and". Note: "and" is a keyword in the C++ 
> language that means itself, so I prefer to use it, not "&&".
> 
> b.) If the parser DID tokenize it correctly, the compiler would still 
> give you an error message, since you are asking for the address of an 
> address, but an address is just a number, it has no address any more 
> than you can ask for the address of "3". An address is not an "l-value" 
> where "l-value" is the term for the kind of value that can appear on the 
> left side of an assignment statement. "foo=2;" is legal because foo is 
> an l-value. "2=foo;" is not legal because 2 is not an l-value. "&foo" is 
> legal, "& & foo" is not.
> 
> Your question contains its own answer:
> 
> FSRef originalRef;
> 
> void Func1(FSRef *fsRefp){
> 
> //... does something with it here.
> 
> }
> 
> void Func2(FSRef *fsRefp){
>    Func1(&originalRef); // Note 1 below
>    Func1(fsRefp);
> }
> 
> //         "In the body of the function is a function call"
> // Note 1: "that also takes a pointer to an FSRef"
> 
> Since it takes what you've already got, you just pass it.
> 
> Func2(&originalRef);

Of course.

I think the only thing being short-circuited was my brain.
0
Steven
1/15/2005 6:52:00 PM
Reply: