Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C: Is the inline keyword worth it?

Is it worth it to use the inline keyword or the compiler is smart enough to know when he needs to inline a function ?

like image 581
Suugaku Avatar asked Sep 06 '10 09:09

Suugaku


1 Answers

Yes, it is smart enough. But what has made no progress at all in the past 40 years is the way C programs are built. It is still one source code file at a time.

So to get a function inlined in more then one .c file you put the function definition in the .h file. And if you don't mark them inline, the linker will complain about the multiple definitions.

like image 115
Hans Passant Avatar answered Oct 01 '22 23:10

Hans Passant