Hi Saurav, I don't know why it is not much used, maybe Greg or Xiang have some idea.
I think the most common use of const for variables that you want to keep in flash to avoid keeping it in RAM (to save RAM space for MCU with low RAM memory). The side effect on this case is Flash access is slower. BR, Alan On Thu, Jul 11, 2024 at 3:16 PM Saurav Pal <resyfer....@gmail.com> wrote: > Hi all, > > Suppose I have a pointer that I want to pass through function parameters. > In the function, neither is the pointer reassigned, nor is the thing it > points to modified in any form. > > So, I would assume its function argument signature to be like FAR const > struct my_struct * const ptr (The second "const" is my focus here). > Similarly for things like const uint8_t my_num, etc. as well. > > However, I have not really seen much use of specifying constants using > const (in the way I have mentioned above). Most of the examples I see are > of FAR const struct my_struct * ptr. I have heard the compiler can make > better optimizations for const, and because of this, I try to spam const > anywhere and everywhere I can. But I don't see too many such usages across > the codebase, so I was wondering why that is (or I just maybe reading the > code wrong, in which case, forgive me 🙏). > > Regards, > Saurav Pal. >