Macro vs. Function
Advantages of a macro over a function?
Macro gets to see the Compilation environment, so it can expand __DATE__ __TIME__ __FILE__ #defines. It is expanded by the preprocessor.
For example, you can't do this without macros.
#define PRINT(EXPR) printf( #EXPR "=%d\n", EXPR) PRINT( 5+6*7 ) // expands into printf("5+6*7=%d", 5+6*7);
You can define your mini language with macros:
#define strequal(A,B) (!strcmp(A,B))
Macros are a necessary evils of life. The purists don't like them, but without it no real work gets done.
2007-02-26, 6923👍, 0💬
What is difference between Association, Aggregation and Inheritance relationships? In object oriente...
How can I enable session tracking for JSP pages if the browser has disabled cookies? We know that se...
What is the version information in XML? “version” tag shows which version of XML is used.
What Is URI? URI (Uniform Resource Identifier) is a superset of URL. URI provides a simple and exten...
.NET INTERVIEW QUESTIONS - What is the difference between thread and process? A thread is a path of ...