How are macros different from inline functions?
Answer / Anuj Kumar Sharma
Macros and inline functions are both used to expand code at compile time, reducing the need for function calls. However, they have some key differences:n
1. Semantic issues: Macros can lead to semantic errors because their behavior is not checked by the compiler until expansion. Inline functions are compiled like regular functions and do not suffer from this issue.
2. Readability: Macros can make code less readable because they expand into unstructured blocks of text, making it harder to understand what's happening.
3. Maintenance: Macros can be more difficult to maintain than inline functions because changes in the macro definition can affect multiple places where the macro is used.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is risc architecture?
What could be the reasons for a system to have gone blank and how would you debug it?
What is inversion of control? How does that relate to dependency injection?
Can you name any code testing tools?
What is interrupt latency? How can you reduce it?
What is a 'volatile' variable?
What is solid?
What is your experience with technical documentation?
You have two computers, and you want to get data from one to the other. How could you do it?
Who are the gang of four? Why should you care?
Tell me what are the 4 types of inheritance relationship?
Explain the concept of convention over configuration, and talk about an example of convention over configuration you have seen in the wild.