Tuesday, 15 September 2015

c - ((always_inline)) does not work when function is implemented in different file -



c - ((always_inline)) does not work when function is implemented in different file -

i have file funcs.h have declaration of function:

inline void some_func( void ) __attribute__((always_inline));

then have file funcs.c have implementation of function:

inline void some_func( void ) { … }

then in main file main.c #include funcs.h , seek utilize some_func() somewhere in code. when compile programme , @ binary file, function appears compiled regular separate function, , called other regular function, instead of beingness embedded inline.

why happening, , there way forcefulness actual inlining this? (except alternative of using #define macros instead of functions, of course.)

put implementations header. if they're not available in translation unit in intend inlining, you'll out of luck. linker (well, traditional linker) can't you.

c gcc inline-functions

No comments:

Post a Comment