Inline qualifier stems from prototype or definition?

后端 未结 4 2382
鱼传尺愫
鱼传尺愫 2021-02-13 18:55

I\'m not quite sure about this in the standards. Say I have three files like this:

foo.h

#include 

inline void foo();

         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-13 19:31

    C++0X draft N3225 says in 7.1.2 Function specifiers:

    • clause 2: A function declaration with an inline specifier declares an inline function
    • clause 4: An inline function shall be defined in every translation unit in which it is odr-used and shall have exactly the same definition in every case.

    So, to me, it looks like gcc is right & clang wrong, but there's still a (slim) chance that things were (are?) different in C++03..

提交回复
热议问题