What is the difference between macros and inline functions?

Answer Posted / vishal

1> Macros are always expanded by pre-processor, whereas compiler may or may not replace the inline definitions. You cant force compiler to make a function inline. It is purely compiler based decision.

2> Debugging macros is also difficult.

3>  Expressions passed as arguments to inline functions are evaluated once. In some cases, expressions passed as arguments to macros can be evaluated more than once.

Here i got exact answer : http://www.firmcodes.com/difference-macro-inline-c/

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to write c functions that modify head pointer of a linked list?

718


Write a Program to find whether the given number or string is palindrome.

956


Why #include is used in c language?

769


How is pointer initialized in c?

770


What do you understand by normalization of pointers?

801






Which is best book for data structures in c?

791


How can I open a file so that other programs can update it at the same time?

881


How to write a code for reverse of string without using string functions?

1805


please send me the code for multiplying sparse matrix using c

1916


Explain what is the benefit of using const for declaring constants?

781


What is a ternary operator in c?

836


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

1703


Define Spanning-Tree Protocol (STP)

852


What is difference between class and structure?

806


find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }

2043