문제

As I know, C inline function body should be defined in .h file because it causes an error '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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top