Topic : C-Language Documentation Author : John Kormylo Version : C.HYP 1.0 Subject : Documentation/C-Language Nodes : 233 Index Size : 6362 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : en @default : @help : Help @options : +g -i -s +x +z -t4 @width : 75 View Ref-File[ #define ] #define macro text #define macro(arg, ...) text arg text #define macro(arg, ...) text(arg)text #define macro(arg, ...) text ## arg #define macro(arg, ...) "text" # arg where 'macro' is a macro name, 'arg' is an argument name, and 'text' can be any combination of characters (except '#' and '\'). The '##' operator causes the surrounding blanks to be removed. The '#' operator causes the surrounding strings to be merged ('arg' must be a string constant). Wherever the 'macro' appears in the source code, it will be replaced by the 'text'. Also, 'macro' will now satisfy the #ifdef directive. Examples: #define DEBUG #define NULL 0 #define SQUARE(x) (x) * (x) #define PACK_INT(a,b) ( ( ((int) (a)) << 8) | ((b) & 255) ) #define PATH(member) "C:\FOLDER\" # member Note: Because macros work by symbolic substitution, using '++' or '--' in a macro argument can have unexpected results: j = SQUARE(i++); /* j = i * (i+1); i += 2; */ See also Preprocessor, Names, #undef, and Predefined Macros.