What is the difference between macros and inline functions?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
What is the proper way of these job Tell me about there full work
Write a C/C++ program that connects to a MySQL server and checks intrusion attempts every 5 minutes. If an intrusion attempt is detected beep the internal speaker to alert the administrator. A high number of aborted connects to MySQL at a point in time may be used as a basis of an intrusion.
write a program to print largest number of each row of a 2D array
What is output redirection?
what is the difference between structure and union?
what is the difference between declaration ,defenetion and initialization of a variable?
write function to reverse char array ... without using second array
Write a program for finding factorial of a number.
What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }
how would a 4*3 array A[4][3] stored in Row Major Order?
What's the difference between struct x1 { ... }; and typedef struct { ... } x2; ?
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.