Page 1 of 1

Inline functions

Posted: Thu Feb 26, 2004 6:41 pm
by HOS
Hi, i am in the process of converting my kernel code from one main file that includes everything to .c files that are compiled into separate .o files and then linked together. my question is this: i have several functions like outportb, enable_ints, etc... that i have been using as 'inline' because they are very simple functions. i dont believe that i can keep them as inline if they are in a separate .o file from whatever is calling them, so the question is do i just define these functions in the main kernel file so they can still be inline? will that even work for other .o files to call them then? or is it not worth it / feasible to even keep them as inline functions?

thanks

Re:Inline functions

Posted: Thu Feb 26, 2004 7:07 pm
by sup
write your code as c code but write these functions as inline c++ funtions and put em in .h files then use a c++ compiler as long as your not using any of the troublesome features of c++ this shouldn't be a problem and should give the funtionality that you want... but who knows I may just be speaking out of my @$$.

Re:Inline functions

Posted: Thu Feb 26, 2004 7:32 pm
by HOS
ah - i think you have something there. i dont know why using c++ would be necessary, but stupid me i never even thought of putting the inline function itself in the .h file, then every "module" would have access to the inline function - i think this should work

thanks!

Re:Inline functions

Posted: Fri Feb 27, 2004 12:47 am
by Solar
C as devised by K&R doesn't have provisions for declaring a function "inline" - that was left to the compiler to decide. Later revisions of the C standard introduced that keyword, so you could use "gcc -std=c99" instead of "g++". (C++ had "inline" right from the start.)