W8118 Inline member function in Package class (C++)

From RAD Studio
Jump to: navigation, search

Go Up to Compiler Errors And Warnings (C++) Index

A class is marked PACKAGE -- for example, __declsepc(package) -- to let the compiler know that it's implemented in a package. This means that the package exports the class and consumers import the class. Therefore the compiler will issue a warning when it sees a member function marked inline in a PACKAGE class. This happens because the inline suggests to the compiler that the function should not really be exported/imported, but that it should be expanded in-place in the body of the caller.

#include <System.hpp>
#include <Classes.hpp>
#include <iostream>

class PACKAGE TFoo : public TComponent
{
     public:
            void inline bar() { std::cout<<"I warn people"<<std::endl;} // W8118

};

Whenever possible, the compiler will honor the 'inline' request of methods of a class marked PACKAGE. But it will also generate a warning as the inline request is in contraction with the PACKAGE specifier.

You must determine whether each inline method of a PACKAGE class is really safe to be inlined. If yes, you can ignore the warning or disable it.