What is the difference between macros and inline functions?

Answers were Sorted based on User's Feedback



What is the difference between macros and inline functions?..

Answer / kiran kumar yakkala

Macro- does not involve in compilation if there is any
logical error also just replaces the code
inline- look like function, but control doesn't goes to
fucntion and execute, it simply replaces the code like
macro but involves in compilation.

Is This Answer Correct ?    9 Yes 2 No

What is the difference between macros and inline functions?..

Answer / karna

when macro function executing the program control go to that macro function definition part
when inline function executed the definition part of function
came in inline functin call part and executed...program control not chance in any where of the program...

Is This Answer Correct ?    7 Yes 3 No

What is the difference between macros and inline functions?..

Answer / rahul sharma

Macro is a must do thing whearas inline is a hint to the compiler. he may choose not to inline if the function seems complex (it uses recursion or many loops)

Macro can have side effects e.g. the typical
SQUARE(++i); problem

but these problem are not there in inline functions

Is This Answer Correct ?    2 Yes 0 No

What is the difference between macros and inline functions?..

Answer / 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

What is the difference between macros and inline functions?..

Answer / jayapradap a

the way they are handled. Inline functions are parsed by the compiler, whereas macros are expanded by the C++ preprocesso these are The major difference between inline functions and macros

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What are control structures? What are the different types?

0 Answers  


write a program to swap two variables a=5 , b= 10 without using third variable

5 Answers  


What is main void in c?

1 Answers  


how to find out the biggest element (or any other operation) in an array which is dynamic. User need not to mention the array size while executing.

3 Answers  


What's the best way to declare and define global variables?

7 Answers  


How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

2 Answers   CMC, Wipro,


who invented c

13 Answers   IBM,


What is stack in c?

0 Answers  


Write a program to use switch statement.

0 Answers   Agilent, Integreon, ZS Associates,


int *a[5] refers to

12 Answers   TCS,


write a program to find the number of even integers and odd integers in a given array in c language

13 Answers   IAI Cameroun, NIIT, Olive Tech, QIS,


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

0 Answers   Aegis, CDAC, Infosys,


Categories