Write-only variables

Alan J Rosenthal flaps at dgp.toronto.edu
Fri Sep 15 08:37:49 AEST 1989


raph at tigger.planet.bt.co.uk (Raphael Mankin) writes:
>How does one declare write-only variables in C?
[ explanation of the use of write-only variables deleted ]

You cannot write to a variable in C without having an lvalue expression for
that variable.
All lvalue expressions in C have meaning as rvalues.%
Therefore, you cannot declare write-only variables in C.
(I think :-))

You can't even fake it with a macro, I don't think.
(Like "#define x (x_real + 0)" for faking const.)

ajr

% humourously, in ansi C, not all lvalue expressions in C have meaning as
lvalues (namely, array names).



More information about the Comp.lang.c mailing list