Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple const in one variable declaration

Tags:

c

constants

ansi

A colleague of mine is going a bit nuts with const in ANSI C and I wanted to know what you guys thought about it. He writes stuff like this for example:

const uint8* const pt_data

I understand where he's going with this but for me it makes the reading and maintainability harder with all these const everywhere.

like image 960
Leo Avatar asked Nov 27 '22 22:11

Leo


1 Answers

It's a const pointer pointing to const data.

  • The first const prevents *pt_data = 10;
  • The second const prevents pt_data = stuff;

It looks like it can be pretty legitimate.

like image 92
cnicutar Avatar answered Dec 10 '22 16:12

cnicutar