[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/6] Use _tmain() instead of main() when compiling on Windows



---
 RHSrvAny/RHSrvAny.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/RHSrvAny/RHSrvAny.c b/RHSrvAny/RHSrvAny.c
index 12d9884..0aa9470 100644
--- a/RHSrvAny/RHSrvAny.c
+++ b/RHSrvAny/RHSrvAny.c
@@ -61,14 +61,30 @@ argument_error (const char *msg)
     return EXIT_FAILURE;
 }
 
+static int compat_tmain (int argc, TCHAR *argv[]);
+
+#ifdef __MINGW32__
 int
-main (int argc, char **a_argv)
+main (int argc, char **argv)
 {
-    /* For compatibility with MinGW, see:
-    http://demosten-eng.blogspot.com/2008/08/mingw-and-unicode-support.html */
-    TCHAR **argv;
-    argv = CommandLineToArgvW (GetCommandLineW (), &argc);
+#ifdef UNICODE
+    TCHAR **w_argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+    return compat_tmain(argc, w_argv);
+#else
+    return compat_tmain(argc, argv);
+#endif
+}
+#else
+int
+_tmain(int argc, TCHAR *argv[])
+{
+    return compat_tmain(argc, argv);
+}
+#endif
 
+static int
+compat_tmain (int argc, TCHAR *argv[])
+{
     size_t i;
     for (i = 1; i < argc; i++) {
         TCHAR *arg = argv[i];
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]