cygwinnewlinecobol

STOP RUN wmissing-newline. Can somebody explain this COBOL error?


I've recently picked up on COBOL coding and have been following Derek Banas tutorial video on it. I decided to test out the IF/ELSE coding on my own, but every time I create a new file and compile it on cygwin I get this error:

$ cobc -x ifelse.cbl

    ifelse.cbl:21: warning: line not terminated by a newline [-Wmissing-newline]
       19 | END-IF
       20 |
       21 > STOP RUN.<EOF>

This is how my code looks like:

       >>SOURCE FORMAT FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. ifelse.
AUTHOR. Anna.
DATE-WRITTEN. April 23rd 2025.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Age PIC 99 VALUE 0.

PROCEDURE DIVISION.
DISPLAY "ENTER AGE: " WITH NO ADVANCING
ACCEPT Age
IF Age > 18 THEN
       DISPLAY "YOU CAN VOTE"
ELSE
       DISPLAY "YOU CAN'T VOTE"
END-IF

STOP RUN.

I don't get this error from the file I use for Derek Banas tutorial, but I get it everytime I create a new COBOL file. The error doesn't seem to have any effect on the file since it runs just fine on cygwin, but it always has some issues with the STOP RUN-line. Is it something I should be concerned and what can I do to stop this error?


Solution

  • This isn't an error but a warning and about the last line of your source not having a trailing line break while containing executable code.

    The compiler used has no problem with it, but others and some processing tools may have. You also see that in several online presentation (like Gitlab and Github), that show a red circle at the end of those files.

    To solve that warning: just position at the end of the file and press enter :-)