Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

static anus

Name: Anonymous 2011-12-11 22:42

are variables declared in C headers static even if you don't put static with them?

Name: >>17 2011-12-13 9:32

To see that it's not a bug in GCC, you have to download the C99 standard: http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf, then head to the section 6.2.2 "Linkages of identifiers" and read it. Paragraph 5 says it as clear as possible:

If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern. If the declaration of an identifier for an object has file scope and no storage-class specifier, its linkage is external.
The `extern` specifier is fucking implied, if there's no other fucking storage specifier. Except for one little detail: if all declarations use actual `extern`, you do get a linker error. Also, you get a linker error if you include initializer more than once (section 6.9.2). Hence, the standard way of declaring global variables: use `extern` in the header, include the header in the corresponding code file, define and initialize the variable there. This way you are safe from most silly errors where you, say, changed the definition but failed to recompile some object files.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List