Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantage of macro over in-line in C++

We know that in-line are favorable as they are checked by the compiler and same operation ( like ++x ) does not evaluate more than once when passed as an argument as compared to macros.

But in an interview I was asked the specific advantages or the circumstances when a macro is more favorable to inline in C++.

Does anyone know the answer or can give a thought on this question ?

like image 510
S..K Avatar asked Jan 25 '11 06:01

S..K


1 Answers

The only thing I can think of is there are some tricks that you can do with a macro that can't be done with an inline function. Pasting tokens together at compile-time, and that sort of hackery.

like image 158
Jeremy Friesner Avatar answered Oct 05 '22 19:10

Jeremy Friesner