Gentee Programming Language > Documentation > Syntax | Download documentation |
The define command is used to specify macros. If the define command has the export attribute, macros are included in object code and can be used in other files. You can assign a constant to a macro, which applies to the following types of constants: a number, a string, a data set or an identifier name, furthermore, you can assign a macro to the value of another macro. Macros are defined enclosed within curly braces, and each line contains only one macro definition. The macro definition consists of a name followed by the equal sign = and the appropriate constant or another macro name.
<macro declaration> ::= <macro name> ['=' (<constant>|<name>) ]
<define> ::= define [<attributes>] '{'<macro declaration> {<end-of-line><macro declaration>} '}'
The specified values are substituted for macros while processing the source program. To get the macro value, you need to use the dollar sign '$' before the macro name.
define { macr_a = 10 //a number macr_b = "This is a string." //a string macr_c = idname //an identifier macr_d = $macr_a //another macro equals 10 }
If a macro is not defined, the enum is considered to be defined and you can assign a macro to the enumerator, that is one larger than the value of the previous one, by default, i.e. the first enumerator has a value of 0, the second one has a value of 1, etc; furthermore, if you specify a value for the previous enumerator, you will start counting from it. Macros can be separated from each other with a space character while enumerating. By using the define command you can define several enumerators at once.
define { macr_0 macr_1 macr_2 new_a = 100 new_b new_c }
See also
![]() |
![]() Copyright © 2004-2006 Gentee Inc. All rights reserved. ![]() |