>> [Do people really not use const and static? -John]
cdg@nullstone.com (Christopher Glaeser) writes:>>2) static - Static can cause significant performance problems for many>C compilers. In particular, few C compilers can keep static variables>in registers over a region of code.

fjh@cs.mu.OZ.AU writes:
|> I think the original poster who suggested using `static' for optimization
|> purposes was suggesting it as an alternative to making variables
|> and functions global, not as an alternative to using auto variables.
|> When used for this purpose, I suspect it may have some effect. For
|> example, compilers may be more inclined to inline a static function.

On 80x86 architecture, making the functions static can be a
significant win, even without inlining. At least one compiler I have
used would always generate a near call for a static function, for
example. (More importantly, this also meant that static functions
always had a near return.)

Sort of the opposite effect, but I also know of a compiler which
systematically loaded the segment register for all accesses to global
variables, even those declared in the module being compiled (even
though it also took pains to set up DS for the data in the module
being compiled).

In practice, the choice between near and far could make an enormous
difference in protected mode, where loading a segment register
involved loading the entire segment descripter (5 words, if memory
serves me right).