Google Answers Logo
View Question
 
Q: Visual Studio C++ .Net 2003 compile error VC++ ( No Answer,   0 Comments )
Question  
Subject: Visual Studio C++ .Net 2003 compile error VC++
Category: Computers > Software
Asked by: fudicator-ga
List Price: $2.00
Posted: 03 Jun 2006 19:47 PDT
Expires: 08 Jun 2006 02:36 PDT
Question ID: 735115
Hello, i've got a really anoying bug that i cant seem to figure out..
The code comes from a 2005 project which needs to be compiled in a
2003 project. The code is as follows:

// CitectAPIManagedDll.h

#pragma once

using namespace System;
using namespace System::Runtime::InteropServices;

namespace CitectAPIManagedDll
{
	/// Create a unmanaged wrapper structure as the placeholder for unmanaged class 
	/// members as exported by the DLL. This structure/class is not intended to be
	/// instantiated by .NET applications directly.
	public __gc struct CitectAPIUnman
	{
		/// Define the virtual table for the wrapper
		typedef __gc struct __VTB
		{
			void (*Open)(CitectAPIUnman*, System::String*, System::String*,
System::String*, System::Int32*);
		};

	public:
		char* id;
		static __VTB *vtb;	

		/// Perform all required imports. Use "ThisCall" calling convention to import 
		/// functions as class methods of this object (not "StdCall"). Note that we 
		/// pass this pointer to the imports. Use the "decorated name" instead of 
		/// retreived from the DLL as the entry point.
		[DllImport("CTAPI.dll", 
				  EntryPoint="ctOpen", 
				  CallingConvention=CallingConvention::ThisCall)]
		static void Open(CitectAPIUnman*, System::String*, System::String*,
System::String*, System::Int32*);
		
		/// Delegates of imported virtual methods for the virtual table.
		/// This basically is hacking the limitation of function pointer (FP),
		/// as FP requires function address at compile time.
		static void VOpen(CitectAPIUnman* w, System::String* computer,
System::String* username, System::String* password, System::Int32*
mode)
		{
			Open(w, computer, username, password, mode);
		}
	};

	/// Managed wrapper class which will actually be used by .NET applications.
	public __gc class CitectAPIWrap
	{
	public: 
		/// User-defined managed wrapper constructor. It will perform a few tasks:
		/// 1) Allocating memory for the unmanaged data
		/// 2) Assign the v-table
		/// 3) Marshall the parameters to and call the imported unmanaged
class constructor
		CitectAPIWrap()
		{
			tv = new CitectAPIUnman();
			CitectAPIUnman::vtb->Open = CitectAPIUnman::VOpen;
		}	

		/// Let the v-table handle method overriding
		virtual void Open(System::String* computer, System::String*
username, System::String* password, System::Int32* mode)
		{
			CitectAPIUnman::vtb->Open(tv, computer, username, password, mode);
		}

	private:
		CitectAPIUnman *tv;
	};
}

i get the following compile error in my header file:
error C2440: '=' : cannot convert from 'void (__clrcall
CitectAPIManagedDll::CitectAPIUnman::*
)(CitectAPIManagedDll::CitectAPIUnman __gc *,System::String __gc
*,System::String __gc *,System::String __gc *,int __gc *)' to 'void
(__clrcall *)(CitectAPIManagedDll::CitectAPIUnman __gc
*,System::String __gc *,System::String __gc *,System::String __gc
*,int __gc *)'

my cpp file is as follows:

// This is the main DLL file.

#include "stdafx.h"

#include "CitectAPIManagedDll.h"

using namespace CitectAPIManagedDll;

/// Unmanaged wrapper static data initialization
CitectAPIUnman::__VTB *CitectAPIUnman::vtb = new CitectAPIUnman::__VTB;

i get the following compile error in my cpp file:
.\CitectAPIManagedDll.cpp(10) : error C2374: 'vtb' : redefinition;
multiple initialization
        c:\pas\source
code\database\citectapimanaged_2003\citectapimanageddll\CitectAPIManagedDll.h(23)
: see declaration of 'vtb'
.\CitectAPIManagedDll.cpp(10) : error C3366:
'CitectAPIManagedDll::CitectAPIUnman::vtb' : static data members of
managed types must be defined within the class definition


any ideas? this is the first time ive used 2003 to compile this
project. your help is greatly appreciated.

thanks.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy