|
Hi David -
If a const is just a pointer to a variable that isn't allowed to be changed ... is there any reason I couldn't take the address of that pointer, assign it to another (non-const) variable, and change the const's value that way?
The compiler won't let you do this, just in case a temporary field is not needed and a pointer to a regular program variable is passed.
If you try to use the %addr other than for testing if it is *null, you get a compiler error:
Msg id Sv Statement Message text
*RNF7586 20 The address of a constant value is used incorrectly. Message . . . . : The address of a constant value is used incorrectly. Cause . . . . . : The address of a constant value cannot be assigned or passed as a parameter. The expression is dropped. Recovery . . . : Correct the value being assigned or passed as a parameter. Compile again.In older releases, the compiler wouldn't even let you test against *null, so you could define a parameter as CONST OPTIONS(*OMIT) but couldn't actually test if it was *OMITted or not. That has been fixed in newer release(s).
Ken http://www.ke9nr.net/ Opinions expressed are my own and do not necessarily represent the views of my employer or anyone in their right mind.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.