In my implementation, I use a pointer to a struct
that can be modified at any time from my code ; I want that, from the exterior of my code, that pointer can be accessed, but only for reading (to be able to use it in certain functions of utility).
struct Thread;
extern volatile struct Thread *const CurrentThread;
volatile
because it will be changed from a
interrupt handler (for now, only for Unix), and I want
that the compiler knows. It is always possible to cast, but at least the compiler warns if you try to change its value inadvertently .
The questions are:
- Is that statement correct to achieve the objectives described? ?
- If the answer is negative, how can the desired effects be achieved?
EDITO - To leave the question somewhat clearer and more specific:
Pointer to struct
:
struct Thread *
Pointer constant to struct
(the pointer itself can not be modified):
struct Thread *const
Pointer constant to struct
. We can not change the value of the pointer, but it can change at any time outside the compiler's control:
volatile struct Thread *const
Is this last correct?