John,
the problem is that if you initialize a PL/1 structure by simply writing
STRUCT = '';
and the structure contains pointers, these pointers are initialized
to NULL, not SYSNULL. Admitted: I did not check so far if there is
a compiler option to change this behaviour, but even if there was one,
it would be hard to convince the compiler people responsible for the
PL/1 compiler to set this option, given the large and unflexible
organization
I am working with.
To have the pointers initialized by SYSNULL, you have to write
STRUCT = '';
folllowed by
STRUCT.ptr1 = SYSNULL ();
STRUCT.ptr2 = SYSNULL ();
STRUCT.ptr3 = SYSNULL ();
STRUCT.ptr4 = SYSNULL ();
...
for every pointer inside the structure (and there are many).
This still may be okay.
The problem occurs, when you change the structure definition
(which is part of an include file), you add a pointer there, and
you DON'T WANT that all your callers have to change their
source code. Simple recompile should be sufficient.
That was our use case. So I decided to do the NULL to SYSNULL
translation on the C side.
INIT on the structure definition is no option; the initialization
must be done by the caller at a certain point in time.
Maybe this topic should be moved to the PL/1 list ...
to see if there is a nice solution on the PL/1 side. Moving
hex zeroes to the struct is no option, too, because there are
possible DEC FIXED fields in it, which should be initialized
to zeroes properly.
Kind regards
Bernd
Am 28.03.2014 15:36, schrieb John Gilmore:
Bernd,
I do not know what control you have over user code that invokes yours,
but PL/I has for long supported the use of sysnull rather than null,
i.e., '000000000'B4 instead of 'FF000000'B4 as the null,
points-nowhere, EOL, pointer value.
Moreover, a PL/I preprocessor procedure that 1) replaces all instances
of null in a PL/I source program with instances of sysnull and 2)
ensures that any PL/I source program that then contains one or more
instances of sysnull also contains one and only one instance of the
declaration
declare sysnull builtin ;
is easy to construct. (I have one that you are welcome to have a copy of.)
I am not sure that I fully understand your users' problems, but null
should long since have been eliminated from their source programs, and
a compile-time solution is much to be preferred to an execution-time
one.
John Gilmore, Ashland, MA 01721 - USA
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN