but if the plugin are loaded the game crashed.
It must be __stdcall without name decoration.
plugin_bas.dll create a beep if loaded than the game crashs.
plugin_c.dll create a beep if loaded and while it runs without any problem.
Any idea why C++ works but not the FreeBASIC build ?
Joshy
file: plugin_bas.bas
Code: Select all
Extern "Windows-MS" ' <--- using stdcall without @XX name decoration
sub Start (byval pForm as any ptr) export
beep()
end sub
sub Finalize () export
beep()
beep()
end sub
sub AccessVariable (byval Index as ushort, byval Value as single ptr, byval blnWrite as ubyte ptr) export
end sub
sub AccessTrigger (byval Index as ushort, byval blnActive as ubyte ptr) export
end sub
end extern
file: plugin_c.h
Code: Select all
#ifndef __PLUGIN_H__
#define __PLUGIN_H__
#ifdef WIN32
#include <windows.h>
#else
#error Target must be WIN32 !
#endif
extern "C" void __stdcall Start(void* form);
extern "C" void __stdcall AccessVariable(unsigned short varindex, float* value, bool* write);
extern "C" void __stdcall AccessTrigger(unsigned short triggerindex, bool* active);
extern "C" void __stdcall Finalize();
#endif // __PLUGIN_H__
Code: Select all
#include "plugin_c.h"
void Start(void* form) {
Beep(440,500);
}
void AccessVariable(unsigned short varindex, float* value, bool* write) {
Beep(440,10);
}
void AccessTrigger(unsigned short triggerindex, bool* active) {
}
void Finalize() {
Beep(220,500);
}