Nested ++Includes

A-Shell supports thirteen levels of nested ++includes. This is primarily useful to allow modular include files to themselves include all of the necessary modules they require, thus relieving the programmer from having to include the entire network of dependent modules in the main source file. Nesting does introduce two complications worth further discussion: how to avoid including the same module twice (see One-Time ++Include), and how to keep track of the hierarchy of nested includes, particularly when it comes to locating the module containing an error flagged by the compiler.

To help you visualize the hierarchy of ++include processing, the compiler normally (absent the /S switch) lists the included file names as it processes them, indenting to indicate the level, e.g.:

.compil sqltest4/x:2

Phase 1 - Initial work memory is 16944 bytes

        Copying from ASHELL.DEF[907,16]

        Copying from FNSQLSTATE.BSI

          Copying from FNEXTCH.BSI[907,10]

?Syntax error (++40) - this is an error

        Copying from FNSQLATR.BSI

...

 

The above example illustrates two levels of ++include processing. The files ashell.def and FNSQLSTATE.BSI are included directly from the main program at the first level, and the file FNEXTCH.BSI is included from within FNSQLSTATE.BSI at the second level, which we can tell based on the fact that it is indented. The standard error message does not directly indicate which file the error occurred in, but it outputs a "+" in front of the line number for each level of ++include nesting. Thus, the "(++40)" tells us that the error was in a module nested two levels below the main program, which could only be FNEXTCH.BSI in this example.

Another option would be to use the COMPIL Background switch, which causes the compiler to output a <prog>.LST file containing details for each error, including the module file name.

Another useful function is offered by the COMPIL List File (LF) switch, which creates a consolidated List File containing all of the ++included modules. The file is designed mainly to use as a cross reference for linking runtime errors to the original source code, but could be used as an aid to studying all the parts of the program in one listing.

Yet another option would be to use The A-Shell Editor, a multi-file program editor capable of identifying all of the included modules associated with the main source and jumping between them as needed.

See Also

Discussion on A-Shell forum.