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 does #define work?

638


What is a const pointer?

623


In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]

1950


Do you know the purpose of 'register' keyword?

636


In a header file whether functions are declared or defined?

625






Explain what is wrong with this program statement?

614


explain what is fifo?

626


if p is a string contained in a string?

1398


How macro execution is faster than function ?

656


Is javascript written in c?

569


is it possible to create your own header files?

629


What is pointer & why it is used?

598


Does sprintf put null character?

587


what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above

663


What is difference between structure and union with example?

586