Note that there are some explanatory texts on larger screens.

plurals
  1. POOperator = is not a member of exported C++ __interface in DLL
    primarykey
    data
    text
    <p>I have been writing some code for a lib and experimented with a default Win32 console application to get everything running. Since I have completed all classes I wanted to extract everything into a DLL and therefore I started the adaptation with the usual macro:</p> <pre><code>#ifdef MYLIB_EXPORTS #define DllExport __declspec(dllexport) #else #define DllExport __declspec(dllimport) #endif </code></pre> <p>I am using one interface in my code which is defined like this:</p> <pre><code>__interface DllExport ISerializable { void Serialize(/* ... */); /* some other methods */ }; </code></pre> <p>And this has worked while gaving this code in my exe. In the DLL I get an error during compilation which states</p> <pre><code>error C2039: '=' : is not a member of 'MyLib::ISerializable' error C2664: 'MyLib::DerivedClass::operator =' : cannot convert parameter 1 from 'const MyLib::ISerializable' to 'const MyLib::DerivedClass &amp;' </code></pre> <p>for every class which inherits <code>ISerializable</code> to implement the required methods. (I am using <code>std::shared_ptr&lt;ISerializable&gt;</code> a few times to have abstraction in my code.) However when I change <code>__interface</code> to <code>class</code> and make all methods pure virtual I do not get this error and compilation succeeds.</p> <p><strong>Why do I get this error? Why does my class/interface in my DLL need the assignment operator? Is there any workaround?</strong></p> <p><em>(Using Visual Studio 2012 RTM on Windows 8 RTM with C++11.)</em></p> <hr> <p>Here is one segment where this error occurs (error point always to the last <code>}</code> of the class):</p> <pre><code>class DllExport Tile final : public ISerializable { public: __declspec(property(get=GetIsPassable, put=SetIsPassable)) bool IsPassable; __declspec(property(get=GetTileId, put=SetTileId)) uint16_t TileId; bool&amp; GetIsPassable() { return this-&gt;_IsPassable; } void SetIsPassable(bool val) { this-&gt;_IsPassable = val; } uint16_t&amp; GetTileId() { return this-&gt;_TileId; } void SetTileId(uint16_t val) { this-&gt;_TileId = val; } bool _IsPassable; uint16_t _TileId; void Serialize(OutputFileStream&amp; ofs); size_t TellSize(); size_t Unserialize(InputFileStream&amp; ifs, size_t metadata = 0); }; </code></pre> <p>This error also occurs in a class where I have a property like in the <code>Tile</code> class where I use a <code>std::shared_ptr&lt;ISerializable&gt;</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload