tips:revmedia:v4i6a3

QTIPS - Handy Compiler Options

Published ByDateVersionKnowledge LevelKeywords
Sprezzatura Ltd01 NOV 19923.0+EXPERTCOMPILER

Peter Walsh of Turner Information Systems strikes again with this QTip about pre-compiler directives.

"The R/Basic pre-compiler supports a very useful undocumented feature. It allows conditional compilation, for example:

#define TESTMODE
.....
#ifdef TESTMODE
  print variable1
  print variable2
#endif

The #define is similar to an equate, but is a directive to the pre-compiler only. Thus the two print statements above will always be executed. However if the #define is commented out, the print statements will be treated similar to comments and will be stripped from the source code before the compiler sees it, and thus will not even appear in the object code. It is great for testing.

The syntax is similar to 'C' pre-compiler directives. However there does not appear to be a #else, but there is a #ifndef (if not defined). This has been tested in Arev 2.12"

Sprezzatura have tested this in version 3.0 as well. In addition to the features described by Peter, the pre-compiler also supports #undefine which permits the unsetting of a flag previously set by #define.

(Volume 4, Issue 6, Page 6)

  • tips/revmedia/v4i6a3.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1