How are macros different from inline functions?



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

Post New Answer

More Embedded Systems AllOther Interview Questions

What is risc architecture?

1 Answers  


What could be the reasons for a system to have gone blank and how would you debug it?

1 Answers  


What is inversion of control? How does that relate to dependency injection?

1 Answers  


Can you name any code testing tools?

1 Answers  


What is interrupt latency? How can you reduce it?

1 Answers  


What is a 'volatile' variable?

1 Answers  


What is solid?

1 Answers  


What is your experience with technical documentation?

1 Answers  


You have two computers, and you want to get data from one to the other. How could you do it?

1 Answers  


Who are the gang of four? Why should you care?

1 Answers  


Tell me what are the 4 types of inheritance relationship?

1 Answers  


Explain the concept of convention over configuration, and talk about an example of convention over configuration you have seen in the wild.

1 Answers  


Categories