MY GOAL
I wanna put my custom STRUCTURE definition and it's methods in a plugin dll, and then use them in my project.

QUESTION
Functions works well, but when I using the structure SED said the structure was a undeclared identifier.

NEED HELP
How can I define a STRUCTURE in a plugin dll and use it in SED?

I HAVE DONE THIS
I learned from the acknex manual and found it only says how to write functions into a dll and call them in .c files at chapter "plugin SDK", follow that I created a dll with one function only use ENGINE OBJECT TYPE. I named this dll "DllTemplate.dll" and copy it to acknex_plugins folder. It works.

I put my structure and methods in the dll source like followed code, Compile and update the acknex_plugins folder files.

Code:
/************************************************
*
*THE "DllTemplate.dll" SOURCE
*Name:DllTemplate.cpp
*Node:Those code compile the DllTemplate.dll file
*Using:VS2008 C++
*
*************************************************/
#include "stdafx.h"
#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <math.h.>
// engine specific header file
#define DLL_USE	// always define before including adll.h
#include "adll.h"

/************************************************
*MY STRUCTURE DEFINE HERE
*************************************************/
typedef struct DllStruct
{
	BMAP *m_pBmap;
}DllStruct;


BOOL APIENTRY DllMain( 
  HANDLE hModule,
  DWORD ul_reason_for_call,
  LPVOID lpReserved)
{
  engine_bind();
  return TRUE;
}

/************************************************
*FIRST FUNCTION, IT WORKS WELL
*************************************************/
DLLFUNC void PanelBgChange(PANEL* pPanel, BMAP *pBmap)
{
  pPanel->bmap = pBmap;
}
/************************************************
*MY STRUCTURE TEST METHOD
*************************************************/
DLLFUNC DllStruct* CreateDllStruct( BMAP *pBmap)
{
	DllStruct *DllStructInst = new DllStruct;
	DllStructInst->m_pBmap = pBmap;
	return DllStructInst;
}



And then I write these in SED to test the dll.
Code:
/************************************************
*
*THE DLL TEST PROGRAM SOURCE
*Name:DllTest.c
*Node:Those code do some tests of the DllTemplate.dll file
*Using:SED
*
*************************************************/
#include<acknex.h>
BMAP *pDllBg = "images\btn_jump.jpg";
BMAP *pBgImg = "images\btn_empty.jpg";

//The test result shower. The panel.bmap shows the different states.
PANEL *pDllTestPanel = 
{
	pos_x = 100;
	pos_y = 100;
	flags = VISIBLE;
	digits(0,0,"Press A",*,0,0); 
}

//Declare the functions defined in dll
void PanelBgChange(PANEL* pPanel, BMAP *pBmap);
DllStruct* CreateDllStruct( BMAP *pBmap);

//main function
function main()
{
	level_load("");
	wait(2);
	//create a dll structure instance
	DllStruct *pDllStructInst= CreateDllStruct(pBgImg);
	pDllTestPanel.bmap = pDllStructInst.m_pBmap;
	while(1)
	{
		if(key_a)
		{
			PanelBgChange(pDllTestPanel, pDllBg);
		}
		else
		{
			PanelBgChange(pDllTestPanel, pBgImg);
		}
		wait(1);	
	}
}



SED told me ERROR:
'DllStruct' undeclared identifier.
<DllStruct* CreateDllStruct( BMAP *pBmap);>.

So I have to put this code in front of main function.
Code:
/************************************************
*
*STRUCTURE DEFINITION 
*Node:This is a part of DllTest.c
*Using:SED
*
*************************************************/
typedef struct DllStruct
{
	BMAP *m_pBmap;
}DllStruct;



This time everything is Ok.

But I wanna put this STRUCTURE DEFINITION in the dll.
How can I do that?

Thanks to read.

Last edited by micmoc; 07/13/09 06:51.