GEOS SDK TechDocs
|
|
2.2 Conditional Code in Goc
|
2.4 Using Routine Pointers in Goc
@define
The C programming language allows definition and use of macros, and most programmers use macros extensively. You can use the
#define
directive in standard C code in your GEOS programs to define macros that use only standard C code.
Similarly, you can use the
@define
Goc directive to create macros in Goc. (Macros must be defined with
@define
; otherwise, the Goc processor will skip the
#define
directive and process the macro as if it were standard code to be processed normally.)
Macros in Goc have a somewhat different syntax than standard C macros though they are very similar. Some examples of simple Goc macros follow below:
@define mlply(val1,val2) val1 * val2 @define defChunk(a) @chunk char a[] = "text"
When using Goc macros in your code, you must preface them with the "
@
" Goc marker, indicating to the processor that it is a macro. If you do not preface the macro with "
@
", then Goc will pass over it and will not process it, leaving it up to the C compiler--which will likely give an error. For example, using the second macro defined above (defChunk), you could create a number of chunks easily:
@defChunk(firstText) @defChunk(secondText) @defChunk(thirdText)
The above would equate to the following:
@chunk char[] firstText = "text"; @chunk char[] secondText = "text"; @chunk char[] thirdText = "text";
Using "defChunk" without the "
@
" marker would most likely result in a compilation error in the C compiler.
GEOS SDK TechDocs
|
|
2.2 Conditional Code in Goc
|
2.4 Using Routine Pointers in Goc