Call VS C++ WForm function from C file

Hi, i get this when I compile my project:

1>object.obj : error LNK2028: unresolved token (0A000009) "void __clrcall set_name(struct DENIB_MESSAGE *)" (?set_name@@$$FYMXPAUDENIB_MESSAGE@@@Z) referenced in function "extern "C" char __clrcall process_contr(struct DENIB_MESSAGE *)" (?process_contr@@$$J0YMDPAUDENIB_MESSAGE@@@Z)
1>object.obj : error LNK2019: unresolved external symbol "void __clrcall set_name(struct DENIB_MESSAGE *)" (?set_name@@$$FYMXPAUDENIB_MESSAGE@@@Z) referenced in function "extern "C" char __clrcall process_contr(struct DENIB_MESSAGE *)" (?process_contr@@$$J0YMDPAUDENIB_MESSAGE@@@Z)
1>C:\Users\eireand\documents\visual studio 2010\Projects\WForm\Debug\WForm.exe : fatal error LNK1120: 2 unresolved externals

I try to call void set_name(DENIB_MESSAGE *) like this in object.c:

#include "set_name.h"
extern void set_name(DENIB_MESSAGE *dmresp);
.
.
.
char process_contr(DENIB_MESSAGE *dmresp)
{
int i;
ERRNO_seq = 0;
ERRNO_type = 0;
switch (dmresp->CODE) {
case CODE_Name:
set_name(dmresp);
.
.
.
and so on

set_name.h:

#ifdef __cplusplus
extern "C"
#endif

#include "framer.h" // for function parameter
extern "C" void set_name(DENIB_MESSAGE *dmresp);


the function in Form1.h
.
.
#include "set_name.h"
.
.
.
public ref class Form1 : public System::Windows::Forms::Form
{
.
.
.
.
void set_name(DENIB_MESSAGE *dmresp)
{
for(int i = 0; dmresp->DATA_SIZE; i++)
{
if(dmresp->DATA[i] != '\0')
inst_name += dmresp->DATA[i];
continue;
}//for
}
.
.
.
How can I fix this???? thank you






Looks like you define set_name() in Form1.h, then you need to include this header file in object.c to resolve this error.
Topic archived. No new replies allowed.