|
-
July 6th, 2009, 03:38 PM
#1
Declaration of office
I have a function in the header Form1.h calling from Motory.cpp.
But not me refer to it.
Do you know what toje?
Declaration:
Motory.cp :
#pragma warning(disable : 4996) // Disable warnings about some functions in VS 2005
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include "stdafx.h"
#include <stdio.h>
#include <tchar.h>
#include <conio.h>
#include <process.h>
#include "USMCDLL.h"
#include "Form1.h"
using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::Windows::Forms;
using namespace Motory_2;
void zapisListBox1(DWORD,char*,char*);
//-----------------------------------------------------
void PrintDevices(USMC_Devices &DVS)
{
for(DWORD i = 0; i < DVS.NOD; i++)
{
zapisListBox1(i, DVS.Serial[i], DVS.Version[i]);
}
}
Declaration Form1.h :
void zapisListBox1(DWORD i, char* Serial, char* Version)
{
this->listBox1->Items->Add("Device - "+(i+1)+",\tSerial Number - "+Convert::ToString(Serial)+",\tVersion - "+Convert::ToString(Version));
}
Error:
Motory_2.obj : error LNK2028: unresolved token (0A000020) "void __clrcall zapisListBox1(unsigned long,char *,char *)" (?zapisListBox1@@$$FYMXKPAD0@Z) referenced in function "void __clrcall PrintDevices(struct USMC_Devices_st &)" (?PrintDevices@@$$FYMXAAUUSMC_Devices_st@@@Z)
Motory_2.obj : error LNK2019: unresolved external symbol "void __clrcall zapisListBox1(unsigned long,char *,char *)" (?zapisListBox1@@$$FYMXKPAD0@Z) referenced in function "void __clrcall PrintDevices(struct USMC_Devices_st &)" (?PrintDevices@@$$FYMXAAUUSMC_Devices_st@@@Z)
C:\Documents and Settings\Brabčáček\Dokumenty\Visual Studio 2008\Projects\Motory_2\Debug\Motory_2.exe : fatal error LNK1120: 2 unresolved externals
Thank you for your help!!
-
July 7th, 2009, 12:26 AM
#2
Re: Declaration of office
zapisListBox1 is Form1 class method, and not global function. You need to call it having Form1 instance reference.
-
July 7th, 2009, 03:18 AM
#3
Re: Declaration of office
 Originally Posted by Alex F
zapisListBox1 is Form1 class method, and not global function. You need to call it having Form1 instance reference.
You mean like this? but it throws me an error too.
Form1::zapisListBox1(i, DVS.Serial[i], DVS.Version[i]);
error:
.\Motory_2.cpp(53) : error C3767: 'Motory_2::Form1::zapisListBox1': candidate function(s) not accessible
-
July 7th, 2009, 04:36 AM
#4
Re: Declaration of office
No, you need Form1 instance for this. It looks like you started to work with C++/CLI without C++ experience. I suggest you to learn C++ first.
In Motory.cpp you need to have variable of type Form1^, which must be initialized to existing Form1 reference. Having this reference, you can call class methods. I cannot show exactly how to do this, because I don't know your program structure.
-
July 7th, 2009, 06:27 AM
#5
Re: Declaration of office
 Originally Posted by Alex F
No, you need Form1 instance for this. It looks like you started to work with C++/CLI without C++ experience. I suggest you to learn C++ first.
In Motory.cpp you need to have variable of type Form1^, which must be initialized to existing Form1 reference. Having this reference, you can call class methods. I cannot show exactly how to do this, because I don't know your program structure.
How do I create a global pointer to Form1, which provide access to its methods?
I tried: public: System:: Windows:: Forms:: Form ^ Fun;
-
July 7th, 2009, 11:42 AM
#6
Re: Declaration of office
To Alex F Thank you very much... This problem is sort out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|