Importing inline functions in MinGW

前端 未结 2 387
渐次进展
渐次进展 2021-01-13 17:39

I\'m using a shared library that defines inline functions in its header.

Here is a reduced test case, as seen by the compilation unit linking to the library (for the

2条回答
  •  囚心锁ツ
    2021-01-13 18:19

    Further information to Chris Dodd's answer:

    I tested with MSVC 2017 and MinGW-w64 7.2.0; in both cases, with optimization enabled, the call of myFunc1() from myFunc2 resolved to the inline version, despite the warning. Even if the body of myFunc1 were moved to below main().

    So my tentative conclusion is that it is safe to ignore this warning.


    In the interest of a clean compile, the only method that seems to work in MinGW-w64 is to mark the function declaration within the class definition as inline. The compiler does not allow applying __declspec(dllimport) to the out-of-class function definition.

    I have been unable to determine if there is a warning flag for g++ which will specifically disable this warning.

提交回复
热议问题