Declaring a struct with typedef
typedef struct some_struct {
int someValue;
} *pSomeStruct;
and then passing it as a parameter to some function with const declaration, implying ‘const some_struct * var’
void someFunction1( const pSomeStruct var )
turns out to become
some_struct * const var
This is also stated in Section 6.7.5.1 of the ISO C standard which states that ‘const’ in this case applies to the pointer and not to the data to which it points.
So the question is – is there a way to declare a pointer to a const struct in a shorthanded notation with typedef, or there must always be a special separate declaration for it:
typedef const struct some_struct *pcSomeStruct;
void someFunction2( pcSomeStruct var )
Basically, do not typedef pointers 🙂
Or, don’t typedef at all 😀