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

static in C

Name: Anonymous 2010-10-16 17:23

I can see why you would want static variables in functions but what's the point of static globals?

Name: Anonymous 2010-10-16 17:57

To remove external linkage.

C doesn't have namespaces, so all global symbols are in the same one and the fewer symbols you make global the less likely you'll have a random collision.

Also, it gives the compiler a bit more leeway in optimizing static functions, since by definition nothing outside the current scope can call it. This makes it more likely to inline functions since a non-inlined copy won't have to be emitted, and (in theory, not practice) also allows the compiler to automatically use non-standard calling conventions.

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