multiple definition of inline function

后端 未结 6 1572
情深已故
情深已故 2020-12-08 19:51

I have gone through some posts related to this topic but was not able to sort out my doubt completely. This might be a very naive question.

I have a header file

6条回答
  •  囚心锁ツ
    2020-12-08 20:30

    Maybe you should post the actual code. The snippets you show don't compile:

    • inline.h has extern inline int func1(void) That doesn't make any sense.
    • main.h has #define I think you meant include instead.

    Once I fixed those and compiled with gcc, it compiled fine and I got the following output

    5
    6
    7
    

    When I compile with g++, I get this output:

    5
    6
    700
    

    That happens because func3() is not static in inline.h

提交回复
热议问题