c++11 - Instantiate inline class method -


i write library, library includes function void f() function 1 line function , when compile library shared object -o3 gcc optimization flag inlined. call in critical place in code (must fast possible) , don't want call not inlined (hits performance substantially). problem function part of api library exposes when library users link library , call function undefined reference linkage error. there way code use function inlined still instantiate in object file library users able link , use it? (when "instantiate in object file" mean i'd see when run objdump -t on shared object). make clear, i'm not interested in solution wrap function

void f() __attribute__((noinline)) { f(); } 

because have many functions , don't want keep copy every function due enormous amount of overhead. i'm looking way tell compiler use inline when definition available it, still instantiate function in object file, library users can link too.

check out how can tell gcc not inline function? found solution appropriate. i'd note main thing code inside library still inlined there no performance penalty users can still use api functions have instantiation

also possible solution in compilation level use -fkeep-inline-functions gcc switch instantiates inline functions , and uses them inlined possible (unlike -fno-inline switch). main problem switch if code heavily templated compilation time longer , binary product becomes bigger


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -