summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-03-19 01:20:21 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-03-19 01:20:21 +0000
commitf5cd7fa9fb50240b10602ba1eb6e52533314a1dd (patch)
tree06cccb757e8807a05ed4c26e840e92723bf4d4e5 /src
parentcf37057367fab0e0c7257a1588d73eba80873d2e (diff)
Changed reading and writing of pointers in Fl_Plugin. This will hopefully fix issues with MinGW.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7302 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Preferences.cxx28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx
index e29d7cb72..962e4a8c8 100644
--- a/src/Fl_Preferences.cxx
+++ b/src/Fl_Preferences.cxx
@@ -1867,9 +1867,15 @@ Fl_Plugin *Fl_Plugin_Manager::plugin(int index)
Fl_Plugin *ret = 0;
Fl_Preferences pin(this, index);
pin.get("address", buf, "@0", 32);
- sscanf(buf, "@%p", &ret);
+ // avoiding %p because it is not (fully) implemented on all machines
+ if (sizeof(void *) == sizeof(unsigned long long) )
+ sscanf(buf, "@%llx", (unsigned long long*)&ret);
+ else if (sizeof(void *) == sizeof(unsigned long) )
+ sscanf(buf, "@%lx", (unsigned long*)&ret);
+ else
+ sscanf(buf, "@%x", (unsigned int*)&ret);
#ifdef FL_PLUGIN_VERBOSE
- printf("Fl_Plugin: returning plugin at index %d: 0x%p\n", index, ret);
+ printf("Fl_Plugin: returning plugin at index %d: (%s) %p\n", index, buf, ret);
#endif
return ret;
}
@@ -1884,9 +1890,15 @@ Fl_Plugin *Fl_Plugin_Manager::plugin(const char *name)
if (groupExists(name)) {
Fl_Preferences pin(this, name);
pin.get("address", buf, "@0", 32);
- sscanf(buf, "@%p", &ret);
+ // avoiding %p because it is not (fully) implemented on all machines
+ if (sizeof(void *) == sizeof(unsigned long long) )
+ sscanf(buf, "@%llx", (unsigned long long*)&ret);
+ else if (sizeof(void *) == sizeof(unsigned long) )
+ sscanf(buf, "@%lx", (unsigned long*)&ret);
+ else
+ sscanf(buf, "@%x", (unsigned int*)&ret);
#ifdef FL_PLUGIN_VERBOSE
- printf("Fl_Plugin: returning plugin named \"%s\": 0x%p\n", name, ret);
+ printf("Fl_Plugin: returning plugin named \"%s\": (%s) %p\n", name, buf, ret);
#endif
return ret;
} else {
@@ -1910,7 +1922,13 @@ Fl_Preferences::ID Fl_Plugin_Manager::addPlugin(const char *name, Fl_Plugin *plu
printf("Fl_Plugin: adding plugin named \"%s\" at 0x%p\n", name, plugin);
#endif
Fl_Preferences pin(this, name);
- snprintf(buf, 32, "@%p", plugin);
+ // avoiding %p because it is not (fully) implemented on all machines
+ if (sizeof(void *) == sizeof(long long) )
+ snprintf(buf, 31, "@%llx", (unsigned long long)plugin);
+ else if (sizeof(void *) == sizeof(long) )
+ snprintf(buf, 31, "@%lx", (unsigned long)plugin);
+ else
+ snprintf(buf, 31, "@%x", (unsigned int)plugin);
pin.set("address", buf);
return pin.id();
}