Preprocessor for BASIC


Most BASICs do not have a pre-processor. ARMbasic  does not include one as part of the standard language, but a version of the CPP has been included as part of the utilities. 

The CPP (C preprocessor) is a very powerful tool, most users use just a fraction of the features,  but if you want the full story check this document from gcc .

As of version 5.14 of BASICtools, the type of CPU is used to generate a #define LPCxxxx that is added before any of the user source code.  This can be used to write code good for any of the CPUs as is done in RTC.bas and HWPMW.bas libraries.

These are the most common directives that apply to use with ARMbasic:  Unlike ARMbasic these keywords and any parameters used in them ARE CASE SENSITIVE.  The pre-processor is run on the PC, so it is not available when using the built-in compiler of the ARMweb. However the compiler with preprocessor can be used to generate files that can be downloaded to the ARMweb (use the Save Intermediates check box in the Files menu of BASICtools).

#include "filename"

#include <filename> 





#if (defined   )







CPP operation

The CPP is a multi-step process carried out automatically by the BASICtools program.  All operations are done in a temp file directory created at %temp%Coridium/temp. All files in this directory will be deleted when a File>>Load is performed by BASICtools.

It starts with your source file, and it will be copied into the %temp%/Coridium directory.  When copied all comments will be stripped.  All included files will be also copied into this temp directory.  Then the CPP will be run on the files in that temp directory creating a __temp.bpp file that is the result of all the pre-processor operations.  This __temp.bpp file will be combined with other information as __temp.bas and then compiled by ARMbasic.exe and its output is __temp.out.   This __temp.out file is a modified Intel hex format of the code generated by the source BASIC program.  __temp.out will be downloaded to the ARM.

In addition __temp.bat and __errors.tmp files will be created.  __temp.bat is a batch file used in the compilation process.  Errors from the compile or any of its steps will be contained in __errors.tmp.