clang: no out-of-line virtual method definitions (pure abstract C++ class)

后端 未结 4 1967
抹茶落季
抹茶落季 2020-11-29 22:00

I\'m trying to compile the following simple C++ code using Clang-3.5:

test.h:

class A
{
  public:
    A();
    virtual ~A() = 0;
};

4条回答
  •  离开以前
    2020-11-29 22:09

    This can be solved in three ways.

    1. Use at least one virtual function which is not inline. Defining a virtual destructor is also alright as far as it is not an inline function.

    2. Disable the warning as shown below.

      #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wweak-vtables" class ClassName : public Parent { ... }; #pragma clang diagnostic pop

    3. Use only .h files for class declarations.

提交回复
热议问题