In my specific case, there is a COPY structure populated in the outermost 
program level that is passed in CALL statements to nested COMMON subprograms 
(which can also CALL each other) and all the COMMON subprograms use the same 
COPY structure to define their LINKAGE parameter.  I just did not and do not 
understand why the compiler cannot use the "local" LINKAGE section definition 
in the nested COMMON subprograms.

There are only two levels of nesting here, outermost and then each COMMON 
subprogram at the same level below that.

This works flawlessly when subprograms are not nested but separately compiled 
as stand-alone units, so I do not see why it is different in a nested version.  
It makes no sense.

Is there a way to tell the compiler that a structure at the OUTERMOST level is 
NOT to be shared with nested programs?  That would solve the particular problem 
that I have, I think.

Peter

-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of Jon 
Butler
Sent: Wednesday, October 13, 2021 9:36 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: COBOL 6.2 - use of identical data name in a nested COMMON 
subprogram generates a IGYPS0037-S compiler error

I think the key is the use of GLOBAL variables: those available to all internal 
subroutines.  Not to be confused with EXTERNAL variables.

GLOBAL are available to all internal subroutines, as long as you don't redefine 
the name in the subroutine.  So if you want only one variable throughout, 
define it in the top level module as GLOBAL.  If you define it in an internal 
subroutine, that is a separate variable, but only available to that subroutine. 
 

EXTERNAL variables are available to any module within the run unit.  You define 
the variable in each module as EXTERNAL, which enables you to have only one 
storage location for the variable in the task.  

A variable an be both GLOBAL and EXTERNAL.

If you have two definitions of the same variable in a single module, they 
should be in different structures, and you need to qualify with the IN or OF 
notation. In that case, you can not use the GLOBAL attribute on either.

--

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to