E
Edward Rutherford
I've got an opaque type encapsulated with a typedef, ie
typedef struct my_obj *my_obj_handle;
What I want is to define a function type that takes one of these
handles in such a way that the function cant modify what's pointed to, in
accordance with Data Hiding principals.
If I do something like
my_function(const my_obj_handle H)
{
*H = something;
}
then this will compile OK because the const applies to H not *H!
Also if I swap the const to the right and have my_function(my_obj_handle
const H) then it's still H that's constant and not *H!
How can I define a function like
my_function(const struct my_obj *H)
but using the typedef instead of struct my_obj?
typedef struct my_obj *my_obj_handle;
What I want is to define a function type that takes one of these
handles in such a way that the function cant modify what's pointed to, in
accordance with Data Hiding principals.
If I do something like
my_function(const my_obj_handle H)
{
*H = something;
}
then this will compile OK because the const applies to H not *H!
Also if I swap the const to the right and have my_function(my_obj_handle
const H) then it's still H that's constant and not *H!
How can I define a function like
my_function(const struct my_obj *H)
but using the typedef instead of struct my_obj?