[vlc-devel] [RFC PATCH 5/7] bin: Convert winvlc to C++

Hugo Beauzée-Luyssen hugo at beauzee.fr
Wed Dec 20 11:34:39 CET 2017


This is required for breakpad integration
---
 bin/Makefile.am              |  5 +++--
 bin/{winvlc.c => winvlc.cpp} | 17 ++++++++++-------
 2 files changed, 13 insertions(+), 9 deletions(-)
 rename bin/{winvlc.c => winvlc.cpp} (93%)

diff --git a/bin/Makefile.am b/bin/Makefile.am
index 23b4100c4b..26cfea507e 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -16,6 +16,7 @@ SUFFIXES = .rc.in .rc
 
 AM_CPPFLAGS = $(CPPFLAGS_vlc)
 AM_CFLAGS = $(CFLAGS_vlc)
+AM_CXXFLAGS = $(CXXFLAGS_vlc)
 if HAVE_DBUS
 AM_CPPFLAGS += -DHAVE_DBUS
 endif
@@ -28,7 +29,7 @@ if !HAVE_WIN32
 vlc_SOURCES = vlc.c override.c
 vlc_LDADD += $(LIBDL)
 else
-vlc_SOURCES = winvlc.c
+vlc_SOURCES = winvlc.cpp
 vlc_DEPENDENCIES = vlc_win32_rc.$(OBJEXT)
 vlc_LDFLAGS = -mwindows
 vlc_LDADD += vlc_win32_rc.$(OBJEXT)
@@ -65,7 +66,7 @@ endif
 # Static (debug) VLC executable
 #
 vlc_static_SOURCES = $(vlc_SOURCES)
-vlc_static_CFLAGS = $(AM_CFLAGS) \
+vlc_static_CPPFLAGS = $(vlc_CPPFLAGS) \
 	-DTOP_BUILDDIR=\"$$(cd "$(top_builddir)"; pwd)\" \
 	-DTOP_SRCDIR=\"$$(cd "$(top_srcdir)"; pwd)\" \
 	$(NULL)
diff --git a/bin/winvlc.c b/bin/winvlc.cpp
similarity index 93%
rename from bin/winvlc.c
rename to bin/winvlc.cpp
index 61a86f1b4b..f35c854cb2 100644
--- a/bin/winvlc.c
+++ b/bin/winvlc.cpp
@@ -65,8 +65,8 @@ static BOOL SetDefaultDllDirectories_(DWORD flags)
 
     BOOL (WINAPI * SetDefaultDllDirectoriesReal)(DWORD);
 
-    SetDefaultDllDirectoriesReal = GetProcAddress(h,
-                                                  "SetDefaultDllDirectories");
+    SetDefaultDllDirectoriesReal = reinterpret_cast<BOOL (WINAPI*)(DWORD)>(
+                GetProcAddress(h, "SetDefaultDllDirectories") );
     if (SetDefaultDllDirectoriesReal == NULL)
         return FALSE;
 
@@ -101,9 +101,12 @@ static void PrioritizeSystem32(void)
     if (SetProcessMitigationPolicy == NULL)
         return;
 #endif
-    PROCESS_MITIGATION_IMAGE_LOAD_POLICY m = { .Flags = 0 };
+    PROCESS_MITIGATION_IMAGE_LOAD_POLICY m;
+    m.Flags = 0;
     m.PreferSystem32Images = 1;
-    SetProcessMitigationPolicy( 10 /* ProcessImageLoadPolicy */, &m, sizeof( m ) );
+    SetProcessMitigationPolicy( /* ProcessImageLoadPolicy */
+                                static_cast<PROCESS_MITIGATION_POLICY>( 10 ),
+                                &m, sizeof( m ) );
 }
 
 int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
@@ -120,8 +123,8 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
      * putenv() call may become redundant with later versions of gettext. */
     putenv("GETTEXT_MUI=1");
 #ifdef TOP_BUILDDIR
-    putenv("VLC_PLUGIN_PATH=Z:"TOP_BUILDDIR"/modules");
-    putenv("VLC_DATA_PATH=Z:"TOP_SRCDIR"/share");
+    putenv("VLC_PLUGIN_PATH=Z:" TOP_BUILDDIR "/modules");
+    putenv("VLC_DATA_PATH=Z:" TOP_SRCDIR "/share");
 #endif
 
 #ifndef NDEBUG
@@ -233,7 +236,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
     {
         libvlc_set_app_id (vlc, "org.VideoLAN.VLC", PACKAGE_VERSION,
                            PACKAGE_NAME);
-        libvlc_set_user_agent (vlc, "VLC media player", "VLC/"PACKAGE_VERSION);
+        libvlc_set_user_agent (vlc, "VLC media player", "VLC/" PACKAGE_VERSION);
         libvlc_add_intf (vlc, "hotkeys,none");
         libvlc_add_intf (vlc, "globalhotkeys,none");
         libvlc_add_intf (vlc, NULL);
-- 
2.11.0



More information about the vlc-devel mailing list