Dear Al,
version 0.35 of gnucap was compatible with mingw and quasi compiled out
of the box (except for the small bug reported in [Bug-gnucap] building
guncap-0.35 in cygwin).
The recently introduced functions CMD::attach and CMD::detach however do
not compile with mingw because dlopen(), dlclose() and dlerror() are not
available in the Windows world (except for Cygwin).
I have made a small patch to c_attahc.cc to allow the attachment of DLLs
under mingw (not really tested so far however). This is also not
compatible to having all non portable functions in md.cc, but at least
allows to compile and run gnucap snapshots under mingw.
Regards
Holger
/* MS Windows portability added to c_attach.cc
* DLLs may be loaded with the following patch
*/
//testing=none
#ifdef _WIN32
#include <windows.h>
#undef min
#undef max
#else
#include <dlfcn.h>
#endif
#include "ap.h"
#include "c_comand.h"
#ifdef _WIN32
/*--------------------------------------------------------------------------*/
static std::map<const std::string, HINSTANCE> attach_list;
/*--------------------------------------------------------------------------*/
void CMD::attach(CS& cmd)
{
int here = cmd.cursor();
std::string s;
cmd >> s;
HINSTANCE handle = LoadLibrary(s.c_str());
if (handle) {
attach_list[s] = handle;
}else{
cmd.warn(bERROR, here, (char*)GetLastError);
}
}
/*--------------------------------------------------------------------------*/
void CMD::detach(CS& cmd)
{
int here = cmd.cursor();
std::string s;
cmd >> s;
HINSTANCE handle = attach_list[s];
if (handle) {
FreeLibrary(handle);
attach_list[s] = NULL;
}else{
cmd.warn(bERROR, here, "plugin not attached");
}
}
#else
/*--------------------------------------------------------------------------*/
static std::map<const std::string, void*> attach_list;
/*--------------------------------------------------------------------------*/
void CMD::attach(CS& cmd)
{
int here = cmd.cursor();
std::string s;
cmd >> s;
void* handle = dlopen(s.c_str(), RTLD_NOW);
if (handle) {
attach_list[s] = handle;
}else{
cmd.warn(bERROR, here, dlerror());
}
}
/*--------------------------------------------------------------------------*/
void CMD::detach(CS& cmd)
{
int here = cmd.cursor();
std::string s;
cmd >> s;
void* handle = attach_list[s];
if (handle) {
dlclose(handle);
attach_list[s] = NULL;
}else{
cmd.warn(bERROR, here, "plugin not attached");
}
}
#endif
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
_______________________________________________
Gnucap-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnucap-devel