what are macros?what are its advantages and disadvantages in
c language?
Answer Posted / ravi ranjan
A macro is a name given to a block of C statements as a
pre-processor directive. Being a pre-processor, the block of
code is communicated to the compiler before entering into
the actual coding (main () function). A macro is defined
with the preprocessor directive, #define.
Like::: #define A 10
#define SUM(x,y) ((x) + (y))
Advantages :::
1.Symbolic constants are evaluated by the PRE-processor,
i.e. they are re-written as literal values, not as
variables. this has some nice side-effects that you can do
using symbolic defines eg. macros and functions inside them.
run-time access to symbolic constants should be
significantly faster than access to variables.
opposite to that, variables (and constants) are evaluated by
the processor (compiler).
2. It is easy to modify the value of the constant
variable,since we have to change the value at the macro
defintion only
DisAdvantages:::
1. Macros are not useful when the function definitions are
Big and when the function is used many number of times.
| Is This Answer Correct ? | 52 Yes | 14 No |
Post New Answer View All Answers
Why do you want to work here
Tell me about your parents?? Pls share any one best words...
What is meant by relay & co-ordination at substation engineering ?
What will be the sql query to list the employee names those are getting 3rd highest salary ?
can i get some win vista notes
what is need of interface. what is the diff b/w interface and abstract class
There are three bucket...Apple,Orange and Apple+Orange....On each Bucket one of the following labels are there..'A','O','A+O'...all this labels are not correctly patched on Bucket..identify which bucket contains What? You can not see bucket..u can pick any number of fruit from any basket...???
Please send the details and fee for Intools training course..I would like to do the course in second week of jUNE 2010.
My system suddenly get off,when i try to power on then it does not work but when i open it and clean RAM and insert it again, it power on.but after some day same problem? please give the answer (i have also changed RAM it's new.)
what is the difference betweeen far pointer and near pointer
I have applied for the post of Section Engineer. plz anyone send me the previous question paper. i did my engineering in Information Technology.
can i knw what are we supposed to read for the coming oces/dgfs 2009 exam?what kind of book are we supposed to study?
how to configure cisco router & switches plz provide me path steps?
WHAT HAPPEN WHEN ANY SPINDLE RUN OVER 10 MM HEIGHT ABOVE BOLSTAR IN RING SPINNING FRAME
How To Servers For Malitnationl Bank?