Skip to content

Instantly share code, notes, and snippets.

@parkercoates
Created April 27, 2018 13:19
Show Gist options
  • Save parkercoates/8f9ae0df05264f06f5ed85b8b6c8aaa4 to your computer and use it in GitHub Desktop.
Save parkercoates/8f9ae0df05264f06f5ed85b8b6c8aaa4 to your computer and use it in GitHub Desktop.
In file included from /usr/include/c++/7.3.1/memory:80:0,
from test/../../../test/MocCompilationIssue.h:4,
from test/moc_MocCompilationIssue.cpp:9:
/usr/include/c++/7.3.1/bits/unique_ptr.h: In instantiation of ‘void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = MyClassB]’:
/usr/include/c++/7.3.1/bits/unique_ptr.h:268:17: required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = MyClassB; _Dp = std::default_delete<MyClassB>]’
test/../../../test/MocCompilationIssue.h:22:40: required from here
/usr/include/c++/7.3.1/bits/unique_ptr.h:76:22: error: invalid application of ‘sizeof’ to incomplete type ‘MyClassB’
static_assert(sizeof(_Tp)>0,
^
#include "MocCompilationIssue.h"
class MyClassA {};
class MyClassB {};
MocCompiles::~MocCompiles() = default;
MocDoesntCompiles::~MocDoesntCompiles() = default;
#pragma once
#include <QObject>
#include <memory>
class MyClassA;
class MocCompiles : public QObject
{
Q_OBJECT
std::unique_ptr<MyClassA> member;
public:
~MocCompiles();
};
class MyClassB;
class MocDoesntCompiles : public QObject
{
Q_OBJECT
std::unique_ptr<MyClassB> member{}; // <-- Note curly braces
public:
~MocDoesntCompiles();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment