Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inline function in c

Tags:

c

function

inline

Can inline function be declared in .h and defined once in .c?

like image 247
Ariel Avatar asked Apr 19 '10 20:04

Ariel


2 Answers

inline function definitions need to be visible wherever the function is invoked. You can define the function in a .c file if you only want to use it within that .c file, otherwise you need to define it in a .h file so that the definition can be #included wherever it is needed.

like image 69
Paul R Avatar answered Sep 22 '22 23:09

Paul R


Yes. It can get messy though here is a good read: http://www.greenend.org.uk/rjk/2003/03/inline.html

like image 39
Nick Van Brunt Avatar answered Sep 21 '22 23:09

Nick Van Brunt