[svn:parrot] r44490 - trunk/src

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Fri Feb 26 02:21:32 UTC 2010


Author: whiteknight
Date: Fri Feb 26 02:21:31 2010
New Revision: 44490
URL: https://trac.parrot.org/parrot/changeset/44490

Log:
fix another warning that appears in g++ because we cast directly from char** to const char**. If we explicitly break type-safety for a bit, we can shut up the warning. Plus, argv here is highly unlikely to be affected by even the most aggressive optimizers, so we don't need to worry about this breaking anything.

Modified:
   trunk/src/main.c

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	Fri Feb 26 02:06:50 2010	(r44489)
+++ trunk/src/main.c	Fri Feb 26 02:21:31 2010	(r44490)
@@ -429,6 +429,11 @@
     ASSERT_ARGS(parseflags)
     struct longopt_opt_info opt  = LONGOPT_OPT_INFO_INIT;
     int                     status;
+    /* g++ complains if we cast char** to const char** directly. However, nobody
+       ever complains if you const to void* first. Sure we lose a certain
+       amount of compiler-enforced type safety, but this is a rare occasion
+       with a very long explanatory comment. */
+    const char ** const _tempargv = (const char **)((void *)*argv);
 
     if (*argc == 1) {
         usage(stderr);
@@ -437,7 +442,7 @@
 
     imcc_start_handling_flags(interp);
 
-    while ((status = longopt_get(interp, *argc, (const char **)*argv, options,
+    while ((status = longopt_get(interp, *argc, _tempargv, options,
             &opt)) > 0) {
         switch (opt.opt_id) {
           case 'R':


More information about the parrot-commits mailing list