Next: preprocessor strings, Previous: preprocessor arguments, Up: preprocessor [Contents][Index]
The preprocessor implements facilities to declare variables with unique names and use them as target
for variables with the NAMEREF attribute. With these facilities we can use the _var
variants
of MBFL functions as follows:
mbfl_local_varref(RV) mbfl_file_extension_var mbfl_datavar(RV) /path/to/file.ext "$RV" ⇒ ext
without risking a variable name collision. In this example, the use of mbfl_local_varref()
expands into:
local mbfl_a_variable_RV mbfl_variable_alloc mbfl_a_variable_RV local $mbfl_a_variable_RV local -n RV=$mbfl_a_variable_RV
a local name variable mbfl_a_variable_RV
is declared and filled with a unique data
variable name by mbfl_variable_alloc()
; then the data variable is declared as local;
finally a proxy variable RV
is defined as alias for the data variable.
Given a proxy variable name defined this way: we can retrieve its name variable name
with the macro mbfl_namevar()
; we can retrieve its data variable name with the macro
mbfl_datavar()
.
Other macros declare variables similarly, using the same scheme of 3 variable declarations: name variable, data variable, proxy variable.
• preprocessor nameref access: | Variables accessors. | |
• preprocessor nameref full: | Full NAMEREF declarations. | |
• preprocessor nameref partial: | Partial NAMEREF declarations. | |
• preprocessor nameref special: | Special NAMEREF declarations. | |
• preprocessor nameref unset: | Unsetting NAMEREF declarations. |
Next: preprocessor strings, Previous: preprocessor arguments, Up: preprocessor [Contents][Index]