Comment

Comment by bb88

The C11 standard is clear here on syntax for a static initializer.

Read section 6.7.9, constraint 4:

  All the expressions in an initializer for an object that
  has static or thread storage duration shall be constant 
  expressions or string literals.
It's syntax, not initialization.

And that makes sense. However the memory is initialized before runtime could be via memcpy() it could be loaded as part of the executable and then mapped dynamically at runtime. That's what 5.1.2 is saying.

What 6.7.9 constraint 4 is saying, is that static variables can only be constant expressions.

parent bb88 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton