In C/C++, why cant a macro take a pointer as an argument ? Thanks, Raul
On Friday 27 June 2003 10:04, Raúl Gutiérrez Segalés wrote:
In C/C++, why cant a macro take a pointer as an argument ?
???! It can! What do you mean, exactly? Post some code that doesn't work. -- "...our desktop is falling behind stability-wise and feature wise to KDE ...when I went to Mexico in December to the facility where we launched gnome, they had all switched to KDE3." - Miguel de Icaza, March 2003
Raúl Gutiérrez Segalés wrote : | In C/C++, why cant a macro take a pointer as an argument ? | | | Thanks, | | Raul Well, it should, i sometimes use the following for debugging : #define strcpy(str1,str2) if (((str1)==NULL) || ((str2)==NULL)) { printf("errmsg\n");} else { strcpy (str1,str2);} (all this is one line !!) Remember that a macro is no more than a litteral substitution, so it might just be a problem with braces, something like the following will not work out like expected : #define bogus(x) x*5 when you use it like this y=bogus(12+3); this will result in y = 12+3*5 which is not the (12+5)*5 you would expect so define your bogus macro like this : #define bogus(x) (x)*5 which will result in y = (12+3)*5; which is (probably) what you expected. Grtz Dries -- <End of message>
participants (3)
-
Derek Fountain
-
dries
-
Raúl Gutiérrez Segalés