![]() |
I want o use the function alternate to a MACRO
> I have a > #define A(a,b,c,d) > sdafasdf/ > sadfsadasd/ > sadfsad/ > sdf. > Now, I have another #define A_function(a,b,c,d) { > asdas; > asdas; > asd;} > Now at runtime, I want to use the function version of the MACRO . > I dont want to use the MACRO, since it is not debuggable > Please help |
Re: I want o use the function alternate to a MACRO
parag_paul@hotmail.com wrote:
> > Now at runtime, I want to use the function version of the MACRO . > > I dont want to use the MACRO, since it is not debuggable > > Please help /* BEGIN new.c */ #include <stdio.h> #define add_5(X) ((X) + 5) int (add_5)(int x) { return add_5(x); } int main(void) { int x = 6; /* ** This uses the macro directly. */ printf("%d plus 5 equals %d\n", x, add_5(x++)); /* ** This uses the function. */ printf("%d plus 5 equals %d\n", x, (add_5)(x)); return 0; } /* END new.c */ -- pete |
Re: I want o use the function alternate to a MACRO
"parag_p...@hotmail.com" <parag_p...@hotmail.com> wrote:
> > I have a > > #define A(a,b,c,d) I presume you meant to add a \ at the end. > > sdafasdf/ > > sadfsadasd/ > > sadfsad/ > > sdf. See... http://c-faq.com/cpp/multistmt.html > > Now, I have another #define A_function(a,b,c,d) { Since this is another macro, but has a different name to the previous macro, I don't quite see what your real question is (though pete has answered what I think you want.) > > asdas; > > asdas; > > asd;} > > Now at runtime, I want to use the function version of > > the MACRO . Macro's stop existing even before compilation. So it's meaningless to say you do or don't want a macro to run at runtime. Please be careful with your terminology, both the macros you've supplied are function macros. So it's not obvious what you mean by "function version the MACRO." > > I dont want to use the MACRO, since it is not debuggable Perhaps you should look into inline functions, though they generally suffer similar problems. This is where log files are often superior to debuggers. -- Peter |
| All times are GMT. The time now is 03:22 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.