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 |
How do we make a global variable accessible across files? Explain the extern keyword?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} what would be the output?
A set of N billiard balls are set on a one-dimensional table. The table is 1 meter long, set north-south with two pockets at either side. Each ball has zero width and there is no friction so it is moving with a fixed velocity of either northward or southward and bounces back in a perfect elastic collision from other balls it encounter on its way (or drop into one of the pockets). Your job is to keep track of the balls movements. Task Please write a program that gets the initial place, speed and direction of all the balls and gives the position of a specific ball after t seconds. Input The first line contains the number of scenarios. Each one of the other lines in the input contains a scenario: The first number, N, is the number of balls; followed by N pairs of numbers: the distance in centimeters from the south end of the table and the speed (positive speed meaning it moves northward); the last two numbers are the number i of the target ball you should track and the time T in seconds. Output The output is a single number for each line which is the place (distance in centimeters from the south end of the table) of the tracked ball after T seconds. Note: There is no new line character at the end of the result. Sample Input 5 1 50 1 1 1000 1 50 1 1 6 1 60 -2 1 6 2 10 1 95 -1 2 30 2 10 1 95 -1 2 60 Sample Output 100 56 48 65 70
GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA
write a programe returns the number of times the character appears in the string
Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?
Determine the code below, tell me exactly how many times is the operation sum++ performed ? for ( i = 0; i < 100; i++ ) for ( j = 100; j > 100 - i; j--) sum++;
sir, i cannot find the way how to write aprogram by using array on queue
What is FIFO?
What is getch c?
Explain about the constants which help in debugging?
What functions are in conio h?