pidgin/pidgin

e128168d9ea5
Parents 00c472cd0fff
Children 558106ebf999
Fix a compilation error on windows and many warnings

SIG_ACK is macro for handling signals on windows. We just want to use it as a
constant, so we #undef if we see it.

Mark a bunch of parameters as unused.

Fix a bunch of warnings about type casting function pointers.

Testing Done:
Compiled and ran on windows.

Reviewed at https://reviews.imfreedom.org/r/2106/
--- a/libpurple/protocols/ircv3/purpleircv3capabilities.c Tue Nov 29 00:06:45 2022 -0600
+++ b/libpurple/protocols/ircv3/purpleircv3capabilities.c Thu Dec 01 03:18:56 2022 -0600
@@ -28,6 +28,14 @@
};
static GParamSpec *properties[N_PROPERTIES] = {NULL, };
+/* Windows is does something weird with signal handling that includes defining
+ * SIG_ACK. We don't care about that here, so we undef it if we find it.
+ * See https://learn.microsoft.com/en-us/cpp/c-runtime-library/signal-action-constants?view=msvc-170
+ */
+#ifdef SIG_ACK
+# undef SIG_ACK
+#endif /* SIG_ACK */
+
enum {
SIG_READY,
SIG_ACK,
--- a/pidgin/meson.build Tue Nov 29 00:06:45 2022 -0600
+++ b/pidgin/meson.build Thu Dec 01 03:18:56 2022 -0600
@@ -176,11 +176,13 @@
input : 'win32/pidgin_exe_rc.rc.in',
output : 'pidgin_exe_rc.rc',
configuration : version_conf)
+
+ pidgin_WIN32_RESOURCES = windows.compile_resources(pidgin_exe_rc,
+ include_directories : include_directories('win32'))
+
pidgin_SOURCES = [
- 'win32/winpidgin.c',
- windows.compile_resources(pidgin_exe_rc,
- include_directories : include_directories('win32')
- )
+ 'win32/winpidgin.c',
+ pidgin_WIN32_RESOURCES,
]
endif
--- a/pidgin/win32/gtkwin32dep.c Tue Nov 29 00:06:45 2022 -0600
+++ b/pidgin/win32/gtkwin32dep.c Thu Dec 01 03:18:56 2022 -0600
@@ -132,7 +132,7 @@
purple_debug_misc("winpidgin", "winpidgin_init start\n");
exchndl_dll_path = g_build_filename(wpurple_bin_dir(), "exchndl.dll", NULL);
- MySetLogFile = (LPFNSETLOGFILE) wpurple_find_and_loadproc(exchndl_dll_path, "SetLogFile");
+ MySetLogFile = (gpointer)wpurple_find_and_loadproc(exchndl_dll_path, "SetLogFile");
g_free(exchndl_dll_path);
exchndl_dll_path = NULL;
if (MySetLogFile) {
@@ -168,7 +168,7 @@
/* DLL initializer */
/* suppress gcc "no previous prototype" warning */
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, G_GNUC_UNUSED DWORD fdwReason, G_GNUC_UNUSED LPVOID lpvReserved) {
dll_hInstance = hinstDLL;
return TRUE;
}
--- a/pidgin/win32/winpidgin.c Tue Nov 29 00:06:45 2022 -0600
+++ b/pidgin/win32/winpidgin.c Thu Dec 01 03:18:56 2022 -0600
@@ -41,6 +41,15 @@
#include <sys/types.h>
#include <sys/stat.h>
+/* We can't include glib.h per the above warning, so we define our own unused
+ * parameter macro.
+ */
+#ifdef __GNUC__
+# define PIDGIN_WIN32_UNUSED __attribute__((unused))
+#else
+# define PIDGIN_WIN32_UNUSED
+#endif
+
typedef int (__cdecl* LPFNPIDGINMAIN)(HINSTANCE, int, char**);
typedef BOOL (WINAPI* LPFNSETDLLDIRECTORY)(LPCWSTR);
typedef BOOL (WINAPI* LPFNATTACHCONSOLE)(DWORD);
@@ -175,9 +184,12 @@
}
-int _stdcall
-WinMain (struct HINSTANCE__ *hInstance, struct HINSTANCE__ *hPrevInstance,
- char *lpszCmdLine, int nCmdShow) {
+int __stdcall
+WinMain(struct HINSTANCE__ *hInstance,
+ PIDGIN_WIN32_UNUSED struct HINSTANCE__ *hPrevInstance,
+ PIDGIN_WIN32_UNUSED char *lpszCmdLine,
+ PIDGIN_WIN32_UNUSED int nCmdShow)
+{
wchar_t errbuf[512];
wchar_t pidgin_dir[MAX_PATH];
wchar_t *pidgin_dir_start = NULL;
@@ -220,8 +232,7 @@
/* Permanently enable DEP if the OS supports it */
if ((hmod = GetModuleHandleW(L"kernel32.dll"))) {
LPFNSETPROCESSDEPPOLICY MySetProcessDEPPolicy =
- (LPFNSETPROCESSDEPPOLICY)
- GetProcAddress(hmod, "SetProcessDEPPolicy");
+ (void *)GetProcAddress(hmod, "SetProcessDEPPolicy");
if (MySetProcessDEPPolicy)
MySetProcessDEPPolicy(1); //PROCESS_DEP_ENABLE
}
@@ -233,8 +244,7 @@
LPFNATTACHCONSOLE MyAttachConsole = NULL;
if (hmod)
MyAttachConsole =
- (LPFNATTACHCONSOLE)
- GetProcAddress(hmod, "AttachConsole");
+ (void *)GetProcAddress(hmod, "AttachConsole");
if ((MyAttachConsole && MyAttachConsole(ATTACH_PARENT_PROCESS))
|| AllocConsole()) {
freopen("CONOUT$", "w", stdout);
@@ -274,7 +284,7 @@
/* Temporarily override exchndl.dll's logfile
* to something sane (Pidgin will override it
* again when it initializes) */
- MySetLogFile = (LPFNSETLOGFILE) GetProcAddress(hmod, "SetLogFile");
+ MySetLogFile = (void *)GetProcAddress(hmod, "SetLogFile");
if (MySetLogFile) {
if (GetTempPathA(sizeof(debug_dir), debug_dir) != 0) {
strcat(debug_dir, "pidgin.RPT");
@@ -285,7 +295,7 @@
}
/* The function signature for SetDebugInfoDir is the same as SetLogFile,
* so we can reuse the variable */
- MySetLogFile = (LPFNSETLOGFILE) GetProcAddress(hmod, "SetDebugInfoDir");
+ MySetLogFile = (void *)GetProcAddress(hmod, "SetDebugInfoDir");
if (MySetLogFile) {
char *pidgin_dir_ansi = NULL;
/* Restore pidgin_dir to point to where the executable is */
@@ -330,7 +340,7 @@
hmod = GetModuleHandleW(L"kernel32.dll");
if (hmod != NULL) {
- MySetDllDirectory = (LPFNSETDLLDIRECTORY) GetProcAddress(hmod, "SetDllDirectoryW");
+ MySetDllDirectory = (void *)GetProcAddress(hmod, "SetDllDirectoryW");
if (MySetDllDirectory == NULL) {
DWORD dw = GetLastError();
const wchar_t *err_msg = get_win32_error_message(dw);
@@ -370,7 +380,7 @@
/* Now we are ready for Pidgin .. */
if ((hmod = LoadLibraryW(LIBPIDGIN_DLL_NAMEW)))
- pidgin_main = (LPFNPIDGINMAIN) GetProcAddress(hmod, "pidgin_main");
+ pidgin_main = (void *)GetProcAddress(hmod, "pidgin_main");
if (!pidgin_main) {
DWORD dw = GetLastError();