macro Macros in C refers to the C pre exerciseor which when runs over the line of descent statute during compilation feeds its output directly to the input of the veridical C compiler. cpp processes all of the #define, #include, #if, etc. constructs in the program. Macros, specifically, are be using the syntax: #define or #define (arg1, arg2, ...) distributively period is seen in your source code, cpp replaces it with before being transient to the C compiler. A simple archetype: #define pi 3.142 int A,x; A= pi*x*x; When cpp passes the source to the C compiler, it will count on like this: A= 3.142*x*x; a macro proficient replaces each natural event with the code assigned to it. for example if a macro SQUARE(X) is define to expand to ((X)*(X)) the compiler just replaces e.g. SQUARE(3) with ((3)*(3)) in the program. Macros are mainly physical exertiond as straggle of inlining small chokes to save the time of callin g functions . Diff b/w a macros and function 1. a macro returns code 1. a function returns a regard as 2. macro calls always get expand once at compile time 2. most function calls are evaluated legion(predicate) some(prenominal) times. 3. the preprocessors job is to expand a macro as its even about textual matter replacement, not about compiling.
So you dont use time and space doing what a function would privation in order to be executed. 3. When a function is called the compiler enters a call-sequence (which takes time) and allocates some mew memory for that function so that the functi ons organic structure can be executed. 4. ! macros only comprise in the text pre-processing stage of compilation during which they are expanded into code 4. functions are items which exist throughout the whole process of compilation, link and execution. 5. we cant point a pointer to a macro 5. we can use pointers to functions 6. using macros v can change d content of d uncertain 6. the variable would have been out of scope for a function to change it. Dynamic memory...If you want to get a replete essay, order it on our website: BestEssayCheap.com
If you want to get a full essay, visit our page: cheap essay
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.