Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
int const max = 15;
int a[max]; /* invalid declaration outside of a function */
int const *p;

p = &max; /* a const-qualified object can have its address taken */
p = &max; 

Wiki Markup
{{const}}\-qualified objects are likely to incur some runtime overhead  \[[Saks 01b|AA. C References#Saks 02]\]. Most C compilers, for example, allocate memory for {{const}}\-qualified objects. {{const}}\-qualified objects declared inside a function body may have automatic storage duration. If so the compiler will allocate storage for the object, and it will be on the stack. As a result, this storage will need to be allocated and initialized each time the containing function is invoked.

...