Re: volatile compile error
Re: volatile compile error
- Subject: Re: volatile compile error
- From: Fritz Anderson <email@hidden>
- Date: Tue, 16 Sep 2008 09:46:37 -0500
On 16 Sep 2008, at 12:24 AM, mark wrote:
Why does 'volatile static MPTaskID AddCacheTask=nil;' generate
'error: invalid conversion from 'OpaqueMPTaskID* volatile*' to
'OpaqueMPTaskID**'?
Line : oe=MPCreateTask(AddToCacheTask, nil, 0, 0, nil, nil, 0,
&AddCacheTask);
MPTaskID :
typedef struct OpaqueMPTaskID* MPTaskID;
Or is it that volatile can't flag pointers?
X-Code 2.5, gcc 4.0.
I have no experience with Multiprocessing Services, but I think my
confusion over your code comes from more than my inexperience.
1. You give both the declaration (volatile static...) and a call tp
MPCreateTask(). Your posting implies that the line on which the error
is reported is the declaration, but your showing the call makes sense
only if the error was on the assignment's line. Which is it?
2. Assuming it's the call, you are passing a pointer to a volatile
value in an argument that expects a pointer to a non-volatile value.
Your declaration tells the compiler that the ID may change while
MPCreateTask() is running. MPCreateTask() is declared (one may presume
it is written) not to expect that. Passing a pointer to a volatile
object into a pointer to a nonvolatile one is an error.
Pass a pointer to a local, non-volatile variable to MPCreateTask, and
assign the result into AddCacheTask if you _really_ need a volatile ID.
My experience of cookie values is that it's hard to imagine wanting to
change such a value arbitrarily. Are you confident in your design?
— F
--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- <http://x3u.manoverboard.org/
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden