Short code to determine compiler's

Walter Bright bright at Data-IO.COM
Tue Jul 25 06:41:00 AEST 1989


In article <1038 at cernvax.UUCP> hjm at cernvax.UUCP (Hubert Matthews) writes:
<I have a question for the authors of smart C compilers: is the
<register declaration useful at all for such compilers?  It indicates
<that a variable is non-volatile, noalias and that taking its address
<is illegal, all of which should make things easier for the optimiser.
For Zortech C:

No, it isn't useful. Non-volatile is the default anyway. Variables are
assumed to be noalias unless:
	1. their address is taken
	2. they are static or global (in which case they can't be register
	   anyway)
The compiler trivially figures out for itself if the address is taken
or not.

<So, does "register" help or hinder?  Has it become a source-code
<"no-op"?  Can I merrily leave it out of my programs and let the
<compiler do the guessing for me :-).

The only effect "register" has is to cause a syntax error if you
took the address of a register variable. "register" should be listed
as an anachronism in the ANSI C spec.

I've seen a lot of effort expended by programmers trying to use the "register"
keyword most effectively. The time they spent doing this would usually pay
for a modern compiler which would do this automatically, and usually with
better results.



More information about the Comp.lang.c mailing list