proposed changes to eliminate P macro

Clive D.W. Feather clive at demon.net
Wed Nov 14 11:40:35 UTC 2007


Jonathan Leffler said:
>>> My own use of "register" isn't to provide compilers with hints but
>>> rather to avoid unintended calls by reference;

> To pass by reference, you have to apply the 'address-of' operator to the
> variable: &variable.
> The register storage class prevents you applying & to a variable.
> 
> But you're correct: except in the weird world of the void pointer (and
> pointer to void pointer, etc), with prototypes in force, you can't pass
> variable where &variable is correct (or vice versa), so forgetting to apply
> the & would be an error spotted by the compiler.

Actually, there's the area of variable length argument lists.

But I think what he meant is that you don't want to set up a pointer to a
variable in one place, thus allowing an unrelated bit of code to try to
modify the variable somewhere else (or, even, worse, outside the lifetime of
that variable). Using "register" means you can't do this until you've
thought through the reasons and deleted the qualifier.

-- 
Clive D.W. Feather  | Work:  <clive at demon.net>   | Tel:    +44 20 8495 6138
Internet Expert     | Home:  <clive at davros.org>  | Fax:    +44 870 051 9937
Demon Internet      | WWW: http://www.davros.org | Mobile: +44 7973 377646
THUS plc            |                            |



More information about the tz mailing list