/pidgin/main: 6d93866a4a3f: Explictly set the calling convention...

Daniel Atallah datallah at pidgin.im
Fri Sep 7 10:39:18 EDT 2012


Changeset: 6d93866a4a3f84a5fae32154867b219613e49e29
Author:	 Daniel Atallah <datallah at pidgin.im>
Date:	 2012-09-07 15:06 +0100
Branch:	 release-2.x.y
URL: http://hg.pidgin.im/pidgin/main/rev/6d93866a4a3f

Description:

Explictly set the calling conventions for some dynamic functions on win32.
This fixes issues when building with newer gcc versions (yay).

diffstat:

 pidgin/gtkmain.c           |   4 ++--
 pidgin/win32/gtkwin32dep.c |   9 +++++----
 pidgin/win32/winpidgin.c   |  23 +++++++++++++----------
 3 files changed, 20 insertions(+), 16 deletions(-)

diffs (108 lines):

diff --git a/pidgin/gtkmain.c b/pidgin/gtkmain.c
--- a/pidgin/gtkmain.c
+++ b/pidgin/gtkmain.c
@@ -465,8 +465,8 @@ show_usage(const char *name, gboolean te
 /* FUCKING GET ME A TOWEL! */
 #ifdef _WIN32
 /* suppress gcc "no previous prototype" warning */
-int pidgin_main(HINSTANCE hint, int argc, char *argv[]);
-int pidgin_main(HINSTANCE hint, int argc, char *argv[])
+int __cdecl pidgin_main(HINSTANCE hint, int argc, char *argv[]);
+int __cdecl pidgin_main(HINSTANCE hint, int argc, char *argv[])
 #else
 int main(int argc, char *argv[])
 #endif
diff --git a/pidgin/win32/gtkwin32dep.c b/pidgin/win32/gtkwin32dep.c
--- a/pidgin/win32/gtkwin32dep.c
+++ b/pidgin/win32/gtkwin32dep.c
@@ -377,7 +377,8 @@ winpidgin_conv_im_blink(PurpleAccount *a
 }
 
 void winpidgin_init(HINSTANCE hint) {
-	FARPROC proc;
+	typedef void (__cdecl* LPFNSETLOGFILE)(const LPCSTR);
+	LPFNSETLOGFILE MySetLogFile;
 	gchar *exchndl_dll_path;
 
 	purple_debug_info("winpidgin", "winpidgin_init start\n");
@@ -385,10 +386,10 @@ void winpidgin_init(HINSTANCE hint) {
 	exe_hInstance = hint;
 
 	exchndl_dll_path = g_build_filename(wpurple_install_dir(), "exchndl.dll", NULL);
-	proc = wpurple_find_and_loadproc(exchndl_dll_path, "SetLogFile");
+	MySetLogFile = (LPFNSETLOGFILE) wpurple_find_and_loadproc(exchndl_dll_path, "SetLogFile");
 	g_free(exchndl_dll_path);
 	exchndl_dll_path = NULL;
-	if (proc) {
+	if (MySetLogFile) {
 		gchar *debug_dir, *locale_debug_dir;
 
 		debug_dir = g_build_filename(purple_user_dir(), "pidgin.RPT", NULL);
@@ -396,7 +397,7 @@ void winpidgin_init(HINSTANCE hint) {
 
 		purple_debug_info("winpidgin", "Setting exchndl.dll LogFile to %s\n", debug_dir);
 
-		(proc)(locale_debug_dir);
+		MySetLogFile(locale_debug_dir);
 
 		g_free(debug_dir);
 		g_free(locale_debug_dir);
diff --git a/pidgin/win32/winpidgin.c b/pidgin/win32/winpidgin.c
--- a/pidgin/win32/winpidgin.c
+++ b/pidgin/win32/winpidgin.c
@@ -38,9 +38,9 @@
 #include <sys/stat.h>
 #include "config.h"
 
-typedef int (CALLBACK* LPFNPIDGINMAIN)(HINSTANCE, int, char**);
-typedef void (CALLBACK* LPFNSETDLLDIRECTORY)(LPCWSTR);
-typedef BOOL (CALLBACK* LPFNATTACHCONSOLE)(DWORD);
+typedef int (__cdecl* LPFNPIDGINMAIN)(HINSTANCE, int, char**);
+typedef void (WINAPI* LPFNSETDLLDIRECTORY)(LPCWSTR);
+typedef BOOL (WINAPI* LPFNATTACHCONSOLE)(DWORD);
 typedef BOOL (WINAPI* LPFNSETPROCESSDEPPOLICY)(DWORD);
 
 static BOOL portable_mode = FALSE;
@@ -692,24 +692,27 @@ WinMain (struct HINSTANCE__ *hInstance, 
 
 			wcscat(pidgin_dir, L"\\exchndl.dll");
 			if ((hmod = LoadLibraryW(pidgin_dir))) {
-				FARPROC proc;
+				typedef void (__cdecl* LPFNSETLOGFILE)(const LPCSTR);
+				LPFNSETLOGFILE MySetLogFile;
 				/* exchndl.dll is built without UNICODE */
 				char debug_dir[MAX_PATH];
 				printf("Loaded exchndl.dll\n");
 				/* Temporarily override exchndl.dll's logfile
 				 * to something sane (Pidgin will override it
 				 * again when it initializes) */
-				proc = GetProcAddress(hmod, "SetLogFile");
-				if (proc) {
+				MySetLogFile = (LPFNSETLOGFILE) GetProcAddress(hmod, "SetLogFile");
+				if (MySetLogFile) {
 					if (GetTempPathA(sizeof(debug_dir) * sizeof(char), debug_dir) != 0) {
 						strcat(debug_dir, "pidgin.RPT");
 						printf(" Setting exchndl.dll LogFile to %s\n",
 							debug_dir);
-						(proc)(debug_dir);
+						MySetLogFile(debug_dir);
 					}
 				}
-				proc = GetProcAddress(hmod, "SetDebugInfoDir");
-				if (proc) {
+				/* The function signature for SetDebugInfoDir is the same as SetLogFile,
+				 * so we can reuse the variable */
+				MySetLogFile = (LPFNSETLOGFILE) GetProcAddress(hmod, "SetDebugInfoDir");
+				if (MySetLogFile) {
 					char *pidgin_dir_ansi = NULL;
 					/* Restore pidgin_dir to point to where the executable is */
 					pidgin_dir_start[0] = L'\0';
@@ -731,7 +734,7 @@ WinMain (struct HINSTANCE__ *hInstance, 
 						debug_dir[sizeof(debug_dir) / sizeof(char) - 1] = '\0';
 						printf(" Setting exchndl.dll DebugInfoDir to %s\n",
 							debug_dir);
-						(proc)(debug_dir);
+						MySetLogFile(debug_dir);
 						free(pidgin_dir_ansi);
 					}
 				}



More information about the Commits mailing list