Menu

Difference between Global and External

M_D
2021-09-16
2021-09-16
  • M_D

    M_D - 2021-09-16

    Hi everyone,

    What 's the difference between use Global versus External?
    A bad use of this statement can create bugs?

    Thank for your help.

     
    • Brian Tiffin

      Brian Tiffin - 2021-09-16

      Last first. Yep.

      First next. In terms of working store GLOBAL is an all programs in tree scope modifier, in WORKING-STORAGE, the name accessible to nested programs. EXTERNAL sets up a run-time managed list of identifiers, shareable by all programs regardless of scope.

      Independently compiled callable programs can use EXTERNAL, as long as they are part of the current libcob. This is relatively expensive, as it's a run-time address resolution, and consistent sizing is the responsibility of the programmer. An error will be raised at run-time if the sizes are not identical for all EXTERNAL address requests. GLOBAL is faster compile/link loader time, and is meant for in source nested program groups.

      GLOBAL gets more complicated with file definitions, but that's almost a separate topic.

      There is, of course, more to it in the edge cases of COBOL. ;-)

      Cheers,
      Blue

       
  • László Erdős

    László Erdős - 2021-09-16

    You can read about it (with small examples) in "GnuCOBOL Programmers Guide":
    https://gnucobol.sourceforge.io/guides.html

    --> 11.6. Sharing Data Between Calling and Called Programs

    László

     
    👍
    1

Anonymous
Anonymous

Add attachments
Cancel