IBM Support

ILE CL NULL Pointer Support Added at Release V6R1

Troubleshooting


Problem

In V6R1, ILE CL was enhanced to include a special value of *NULL that could be used to initialize pointers to NULL and compare pointers against NULL.

Resolving The Problem

In V6R1, NULL pointer support in ILE CL was enhanced with the following additions:

1. Declaration of Pointer Variables

In V5R4 and before, the only way to ensure that a CL Pointer variable was set to NULL was to declare it without any initial value or address. As of V6R1, a pointer variable can be explicitly initialized to have an address of NULL using the ADDRESS parameter on the DCL statement.

Example

DCL VAR(&PTR1) TYPE(*PTR) ADDRESS(*NULL)


2. Changing Pointer Variables using CHGVAR

The special value *NULL can now be used in a CHGVAR statement to explicitly set a pointer to NULL.

CL Code Example

CHGVAR VAR(&PTR1) VALUE(*NULL)


3. Logic Statements

Pointer variables can now be compared against the special value *NULL in conditional statements.

CL Code Example

IF (&PTR1 *EQ *NULL) THEN(DO)

/* Code to execute here */

ENDDO


4. Compiling for TGTRLS(V5R4M0) and TGTRLS(V5R3M0)

Support for using *NULL in CHGVAR and in logic statements has also been extended to the TGTRLS(V5R4) and TGTRLS(V5R3) compilers. However,support for using ADDRESS(*NULL) in the DCL statement was not extended to the TGTRLS compilers.




Note: If the above is followed with an OPM CL program, the program will not compile and you will receive the following message:
CPD0711 30 Operands in expression not same type.

Support for *NULL was added in 6.1 and is valid in DCL statements for both OPM and ILE; however, it is only valid in pointer comparisons in ILE CL.

For OPM, the only way to compare a pointer CL variable to null is to compare it to a dummy CL pointer variable that is never used or declared with ADDRESS(*NULL). For example:

PGM                                                  
DCL        VAR(&NULLPTR) TYPE(*PTR) ADDRESS(*NULL)  
DCL        VAR(&P_DSPOPT) TYPE(*PTR) ADDRESS(*NULL)
:
IF         COND(&P_DSPOPT *EQ &NULLPTR) THEN(SNDMSG +  
    MSG('DSPOPT IS NULL') TOUSR(KPRYKE))            
IF         COND(&P_DSPOPT *NE &NULLPTR) THEN(SNDMSG +  
    MSG('DSPOPT IS NOT NULL') TOUSR(KPRYKE))        
ENDPGM

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.1.0"}]

Historical Number

575980972

Document Information

Modified date:
18 December 2019

UID

nas8N1011952