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, 6639👍, 0💬
How To Insert Multiple Rows with a SELECT Statement? - MySQL FAQs - Managing Tables and Running Quer...
How comfortable are you with writing HTML documents entirely by hand? Everyone has a different prefe...
What are urlencode() and urldecode() functions in PHP? string urlencode(str) - Returns the URL encod...
How do we assign page specific attributes ? Page attributes are specified using the @Page directive.
How To Get the Minimum or Maximum Value of an Array? - PHP Script Tips - PHP Built-in Functions for ...