COMPILER_VERSION Macro

Added February 2015

The compiler internally defines a macro symbol COMPILER_VERSION to the compiler edit number, allowing you use it in a conditional compilation statement to avoid or warn about code that requires a minimum compiler version. For example:

++IFNDEF COMPILER_VERSION

    ++ERROR Compiler version too old (pre 711)

++ENDIF

 

++IF COMPILER_VERSION >= 710

    DEFTYPE BOOLEAN I,2

++ENDIF

 

++IF COMPILER_VERSION < 728

? "Error ";err(0);

++IFDEF ABC_CURRENT_ROUTINE$

     ? " in routine ";ABC_CURRENT_ROUTINE$

++ELSE

    ? " at line #";err(1)

++ENDIF

++IFDEF COMPILER_VERSION

    ++IF COMPILER_VERSION >= 792            ! .LOCATION introduced in

        ? " location counter = "+.LOCATION  !   compiler edit 792

    ++ENDIF

++ENDIF

 

Comments

Unfortunately, since the COMPILER_VERSION macro was introduced in edit 711, an attempt to reference its value in a prior version will generate a "conditional expression not constant" error, so that will only be useful going forward. However, you can use ++IFDEF to test if it's defined—and if not, you will know that it is prior to version 711.

Independent of, but related to, the concept of the minimum compiler version needed to compile a section of source code, is the minimum runtime version needed to execute it. This is not something you can test for or specify at compile time, but as of compiler version 896 (released with A-Shell 6.5.1657), the compiler automatically indicates the minimum runtime version needed (if it exceeds 6.5.1657) in the RUN header, based on the features used in the program. You can use VERSYS.LIT to display the minimum version, if applicable, for any RUN, LIT, or SBX program.

History

2014 October, A-Shell 6.1.1392, compiler edit 711:  added to A-Shell