standards: Errors

1 
1 4.4 Formatting Error Messages
1 =============================
1 
1 Error messages from compilers should look like this:
1 
1      SOURCEFILE:LINENO: MESSAGE
1 
1 If you want to mention the column number, use one of these formats:
1 
1      SOURCEFILE:LINENO:COLUMN: MESSAGE
1      SOURCEFILE:LINENO.COLUMN: MESSAGE
1 
1 
1 Line numbers should start from 1 at the beginning of the file, and
1 column numbers should start from 1 at the beginning of the line.  (Both
1 of these conventions are chosen for compatibility.)  Calculate column
1 numbers assuming that space and all ASCII printing characters have equal
1 width, and assuming tab stops every 8 columns.  For non-ASCII
1 characters, Unicode character widths should be used when in a UTF-8
1 locale; GNU libc and GNU gnulib provide suitable 'wcwidth' functions.
1 
1    The error message can also give both the starting and ending
1 positions of the erroneous text.  There are several formats so that you
1 can avoid redundant information such as a duplicate line number.  Here
1 are the possible formats:
1 
1      SOURCEFILE:LINE1.COLUMN1-LINE2.COLUMN2: MESSAGE
1      SOURCEFILE:LINE1.COLUMN1-COLUMN2: MESSAGE
1      SOURCEFILE:LINE1-LINE2: MESSAGE
1 
1 When an error is spread over several files, you can use this format:
1 
1      FILE1:LINE1.COLUMN1-FILE2:LINE2.COLUMN2: MESSAGE
1 
1    Error messages from other noninteractive programs should look like
1 this:
1 
1      PROGRAM:SOURCEFILE:LINENO: MESSAGE
1 
1 when there is an appropriate source file, or like this:
1 
1      PROGRAM: MESSAGE
1 
1 when there is no relevant source file.
1 
1    If you want to mention the column number, use this format:
1 
1      PROGRAM:SOURCEFILE:LINENO:COLUMN: MESSAGE
1 
1    In an interactive program (one that is reading commands from a
1 terminal), it is better not to include the program name in an error
1 message.  The place to indicate which program is running is in the
1 prompt or with the screen layout.  (When the same program runs with
1 input from a source other than a terminal, it is not interactive and
1 would do best to print error messages using the noninteractive style.)
1 
1    The string MESSAGE should not begin with a capital letter when it
1 follows a program name and/or file name, because that isn't the
1 beginning of a sentence.  (The sentence conceptually starts at the
1 beginning of the line.)  Also, it should not end with a period.
1 
1    Error messages from interactive programs, and other messages such as
1 usage messages, should start with a capital letter.  But they should not
1 end with a period.
1