What is the difference between static const and const?

static determines visibility outside of a function or a variables lifespan inside. So it has nothing to do with const per se.

const means that you’re not changing the value after it has been initialised.

static inside a function means the variable will exist before and after the function has executed.

static outside of a function means that the scope of the symbol marked static is limited to that .c file and cannot be seen outside of it.

Technically (if you want to look this up), static is a storage specifier and const is a type qualifier.

Leave a Comment