Bloomberg LP Interview Question
Software Engineer / DevelopersInline functions are parsed by the compiler, whereas macros are expanded by the preprocessor.
Inline functions follow all the protocols of type safety, Expressions passed as arguments to inline functions are evaluated once. In some cases, expressions passed as arguments to macros can be evaluated more than once.
compiler would expand the inline functions at compile time only. It depends on the compiler whether to do optimization or not. If inline function is too large then compiler wouldn't expand the inline code rather it would follow normal function call procedure (where it pushes the variables on stack, etc.)
Disadvantage of inline function is that it can cause thrashing i.e. page thrashing, cache thrashing. Thrashing is a process where in more memory resources are used for preparing the execution rather than executing the instructions.
1.Typechecking will take place in Inline but not in macro
- Anonymous August 03, 20102.Text substitution will be done during compile time...but in macro pre-processor stage