Note that there are some explanatory texts on larger screens.

plurals
  1. POc++/cli interface header file
    primarykey
    data
    text
    <p>I have a C++ project (visual studio 2010) which consists of native code and c++/cli code as well. I cant compile the whole project with /clr, so I just do it for the respective c++/cli files. My Problem is that a header file cant be compiled with /clr, but I want to make some c++/cli functions reusable within the whole project and therefor define the method prototypes in a header file to include it in every file where I need it. Is there a solution? I have tried to define some mixed code method prototypes in a header file, but /clr must be switched on for that to compile.</p> <p>Here is my example:</p> <p>Test.h</p> <pre><code>#include &lt;Windows.h&gt; #include &lt;vector&gt; #include &lt;string&gt; using std::vector; using std::string; #include &lt;msclr/marshal.h&gt; #pragma managed using namespace msclr::interop; using namespace System; using namespace System::IO; using namespace System::Runtime::InteropServices; public ref class Test { public: int Foo(); }; </code></pre> <p>Test.cpp</p> <pre><code>#include "Test.h" int Test::Foo() { return 4; } </code></pre> <p>Intellisense is complaining with errors in Test.h like c++/cli must be enabled to use #using. But I think this is negligible and it would compile anyway.</p> <p>Compilation aborts with a Linker Error (sry, i have german VS version)</p> <pre><code>Fehler 6 error LNK1255: Fehler bei Verknüpfung aufgrund von Metadatenfehlern. Fehler 4 error LNK2022: Fehler bei Metadatenoperation (8013118D) : Duplizierte Typen (_PROPSHEETPAGEA) wurden gefunden, aber die Typenlayoutinformationen sind nicht konsistent: (0x02000198). Fehler 5 error LNK2022: Fehler bei Metadatenoperation (8013118D) : Duplizierte Typen (_PROPSHEETPAGEW) wurden gefunden, aber die Typenlayoutinformationen sind nicht konsistent: (0x020001d1). </code></pre> <p>I definitely dont have a duplicate class "Test" elsewhere, so I dont know where the duplicate comes from. What are typelayout informations and why are they not consistent?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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