Skip to content

Preprocessor


The Preprocessor performs some processing on source code before the next step of compilation.

The preprocessor is a program that parses a text file and makes it submit to certain transformations.

These transformations can be the inclusion of a file, the deletion of a text block or the replacement of a text block.

The preprocessor performs these operations through specific commands that it reads in the file being scanned.

It is automatically called by the compiler, before compilation, to process the files to compile.

Preprocessor commands

All preprocessor commands begin at the beginning of the line with the pound sign ("#").

See 'Preprocessor commands' to get all commands that control the preprocessor.

The main types of commands are the followings:

  • File inclusion:
  • Text replacement:
  • Compilation constants and conditional compilation:
  • Macros:
  • Other commands:

Example

Example with #include and #define:

start GeSHi

vb
#include "vbcompat.bi"
#define TEMPLATE "hh:mm:ss yyyy/mm/dd"

Dim As String * Len(TEMPLATE) hour_date

hour_date = Format(Now, TEMPLATE)

Print hour_date, "(" & TEMPLATE & ")"

Sleep

end GeSHi

See also

Back to DocToc

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft