Revision [14424]
This is an old revision of KeyPgPpmacro made by CountingPine on 2009-08-29 21:56:29.
#MACRO...#ENDMACRO
Preprocessor directive to define a multiline macro
Syntax:
#macro macro_name( [ param1 [, param_list] ] )
macro body
#endmacroDescription:
#macro defines a function like macro where macro body may span multiple lines.
Parameters supplied to the function like macro are substituted where they occur in the macro body. The entire macro body is substituted where ever macro_name appears in the source code. The number of parameters supplied to a macro must match the number of parameters in its #macro definition.
The KeyPgPpifdef #ifdef and KeyPgPpifndef #ifndef preprocessor conditionals can test if macro_name exists or does not exist.
The KeyPgPpundef #undef preprocessor directive will undefine a macro so that it may be redefined with another definition.
Macro substitution can be checked by using the -g -r switches. The compiler doesn't erase the intermediate .asm file where the code actually sent to the compiler can be seen close to its translation into assembler.
Macro substitution can be checked by using the -g -r switches. The compiler doesn't erase the intermediate .asm file where the code actually sent to the compiler can be seen close to its translation into assembler.
Examples:
'' macro as an expression value
#macro Print1( a, b )
a + b
#endmacro
Print Print1( "Hello", "World" )
'' Output :
'' Hello World!
#macro Print1( a, b )
a + b
#endmacro
Print Print1( "Hello", "World" )
'' Output :
'' Hello World!
'' macro as multiple statements
#macro Print2( a, b )
Print a;
Print " ";
Print b;
Print "!"
#endmacro
Print2( "Hello", "World" )
'' Output :
'' Hello World!
#macro Print2( a, b )
Print a;
Print " ";
Print b;
Print "!"
#endmacro
Print2( "Hello", "World" )
'' Output :
'' Hello World!
Differences from QB:
- New to FreeBASIC
See also:
- KeyPgPpdefine #define
- KeyPgPpif #if
- KeyPgPpelse #else
- KeyPgPpelseif #elseif
- KeyPgPpendif #endif
- KeyPgPpifdef #ifdef
- KeyPgPpifndef #ifndef
- KeyPgPpundef #undef
- KeyPgDefined defined
Back to Preprocessor