Help save net neutrality! Learn more.

#3 Screen Section Initialization Fix

not accepted
screen (1)
Brad Beimer

When compiling screen section items, the CE compiler creates a .c.h.l file with the screen variable assignments. If there are any references to a non 01 level working storage element, then the c code has non-constant values in these assignments. This prevents the code from compiling. For example:

 screen section.
 01 ss-blank-page.
     03 background-color io-h-background-color
        foreground-color io-h-foreground-color.
     05 blank screen.

compiles to:

static cob_screen s_545 = {NULL, NULL, &f_545, NULL, NULL, NULL, ( = b_181 + 229, &f_317), ( = b_181 + 228, &f_316), 1, 0, 128};
static cob_screen s_544 = {NULL, &s_545, NULL, NULL, NULL, NULL, ( = b_181 + 229, &f_317), ( = b_181 + 228, &f_316), 0, 0, 0};
static cob_screen s_543 = {NULL, &s_544, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0};

Which generates an "initializer is not a constant" error.

Here is a patch that addresses the issue. It moves the initialization from the header file into the c file using a new initialization function in codegen.h. The modified files are cobc/codegen.c and libcob/codegen.h.

This is not my original work, I ripped this (with slight modifications to work with CE) from Simon’s windows projects on

Please let me know if this is not the correct method to post patch requests, and also how the priority should be set, since I have a few original ones I’d like to provide.


1 Attachments


  • Brad Beimer

    Brad Beimer - 2013-01-10

    Patch had an issue using codegen.h on CE - I have moved the functionality into screenio.c in this updated (and working) patch.

    • Simon Sobisch

      Simon Sobisch - 2013-11-21

      Hm, there is no compiling error with this in GNU Cobol (checked 1.1 and above). Tested with the attached source.

      Is the test case not correct and/or is the patch not needed any more?


      BTW: As said before you're invited to provide more patches [based on GNU Cobol] :-)

  • Simon Sobisch

    Simon Sobisch - 2013-01-13

    Hi Brad,

    yes, this is a good way to commit patch request. If you want to get involved for more than some patches you could join the devs (just leave a note). Clear fixes are very likely to be accepted, other stuff will be discussed.
    Not sure but possible the patch isn't from me but was posted at the old forum
    I'll try to find some time (may need 2 weeks currently) to have a look at this and commit it. Thank you.


  • Brad Beimer

    Brad Beimer - 2014-01-02

    Apparently this patch is no longer needed.


  • Simon Sobisch

    Simon Sobisch - 2014-01-02
    • status: open --> wont-fix
  • Simon Sobisch

    Simon Sobisch - 2014-07-29
    • Group: Test --> not accepted

Log in to post a comment.