Should C declarations match definition including keywords and qualifiers such as “static”, “inline”, etc

前端 未结 4 639
心在旅途
心在旅途 2020-12-21 02:21

Consider this example of a function declaration and definition (in the same translation unit):

inline static int foo(int x);

...

int foo(int x)
{
  return          


        
4条回答
  •  生来不讨喜
    2020-12-21 02:36

    Yes. inline and static should be include. For example, the line of code for the function should be the same in the .h file where you declare, and the .c file where you define (so yes in both cases), but in your main code.c file it should only have the function name when called, so "foo(parameters passed)".

    Hope this helps!

提交回复
热议问题