Question:
How do you override a defined macro?
Answer:
You can use the #undef preprocessor directive to undefine (override) a previously defined macro. Source: CoolInterview.com
we can redefine it with the same name and a new value. Source: CoolInterview.com
Answered by: rishabh | Date: 3/13/2009
| Contact rishabh
Assume 'NULL' is framework defined MACRO. If you wish to override, then,
#ifdef NULL #undef NULL #define NULL ((void*)0) #endif
Above will override already defined MACRO in the scope. Source: CoolInterview.com
Answered by: Ravi A Joshi | Date: 6/24/2009
| Contact Ravi A Joshi
An elegant way of doing this is shown below:
#ifdef MACRO #undef MACRO #endif
#define MACRO X Source: CoolInterview.com
Answered by: Nileshkumar | Date: 8/22/2009
| Contact Nileshkumar
c is a middle level language that come in category of structural programming language so there is no concept of overriding.one method to do this is to #undef the defined macro and then give new definition to macro. Source: CoolInterview.com
Answered by: kirti | Date: 10/22/2009
| Contact kirti
use the #undef preprocessor directive to undefine the define Macros. Source: CoolInterview.com
Answered by: Joji Joseph | Date: 11/5/2009
| Contact Joji Joseph
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|