(So far, 243 people got it right out of 452 for a success rate of 53%)

What is the purpose for const in the following function prototype?

void Dio_Init(DioConfig_t * const Config);

Pick one:
a) To tell the compiler that the data pointed to cannot change in the Dio_Init function.
b) To tell the compiler that the pointer to the data cannot change in the Dio_Init function.
c) To tell the compiler that both the pointer and the data cannot change in the Dio_Init function.
d) const serves no purpose in this context because it's a passed parameter.


[ - ]
Comment by waydanSeptember 22, 2022
While the answer is technically correct, the use of const in this context does not guarantee the caller anything since the caller's pointer is copied into Dio_Init, nothing in the function can modify the caller's copy of the pointer. Arthur O'Dwyer had a good explanation here

To post reply to a comment, click on the 'reply' button attached to each comment. To post a new comment (not a reply to a comment) check out the 'Write a Comment' tab at the top of the comments.

Please login (on the right) if you already have an account on this platform.

Otherwise, please use this form to register (free) an join one of the largest online community for Electrical/Embedded/DSP/FPGA/ML engineers: