Novice question.

Matthias Ulrich Neeracher mneerach at iiic.ethz.ch
Wed Nov 14 20:56:11 AEST 1990


In article <3838 at vela.acs.oakland.edu> jmwojtal at vela.acs.oakland.edu (Wojo) writes:
>What exactly are the reasons "register" and "extrn" are used to declare
>values.  I see register alot in some of the programs and I don't know why
>they do it.  Is it just good practice or what.

"extern" essentially tells the compiler that this variable is defined 
elsewhere.

"register" is a hint to the compiler that this variable will be used a lot
and that the compiler should try to keep it in a processor register. This
hint was introduced in a time when programmers were smart and compilers were
stupid. Today, the opposite is true :-), so some compilers ignore "register"
hints completely and allocate registers as they see fit.

Matthias

-----
Matthias Neeracher                                   mneerach at iiic.ethz.ch
   "These days, though, you have to be pretty technical before you can 
    even aspire to crudeness." -- William Gibson, _Johnny Mnemonic_



More information about the Comp.lang.c mailing list