3

I came across a warning in Linux system about an array which was declared in usual manner. The warning said that static const char * const should be used instead of just char * . Why is that?

How do I know when should an array be declared static constant?

What does const after char * mean?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
unixia
  • 4,102
  • 1
  • 19
  • 23
  • 1
    For the warning please show the exact code in question. Both cases are valid in different situations. For the last question you probably should just search SO(e.g [here](https://stackoverflow.com/questions/890535/what-is-the-difference-between-char-const-and-const-char)) or the wider web. – kaylum Sep 29 '15 at 23:08
  • `const` after `char *` means the pointer itself is `const`. Whether it's appropriate to use `static` and/or `const` in general depends on the context. – MooseBoys Sep 29 '15 at 23:08
  • use 'const' modifier when the array will never change. use 'static' to 1) remove the array from the stack 2) to make the invisible to other files – user3629249 Sep 30 '15 at 08:08

0 Answers0