开发者

Is there a way to define C inline function in .c file rather than .h file?

开发者 https://www.devze.com 2022-12-29 09:23 出处:网络
As I know, C inline function body should be defined in .h file because it causes an erro开发者_运维问答r \'function-name used but never defined\" if body defined in .c file.

As I know, C inline function body should be defined in .h file because it causes an erro开发者_运维问答r 'function-name used but never defined" if body defined in .c file.

Is this the regular way? Or how to define inline function body in .c file?


Each .c file is compiled independently into .o output. If you define the inline function in a .c file, other source files cannot see such function, so that cannot be inlined.

Therefore the inline function should be in the .h file to allow the code to be shared.

0

精彩评论

暂无评论...
验证码 换一张
取 消