From: Linus Torvalds Date: Thu, 19 May 2005 18:55:52 GMT Subject: Re: [PATCH] Detect renames in diff family. Message-ID: In-Reply-To: <7vy8abys5a.fsf@assigned-by-dhcp.cox.net> On Thu, 19 May 2005, Junio C Hamano wrote: > > Here is another "doubt" point. I am almost embarrassed to ask > this, but what's the right way to express the following? I > could not figure out how to silence const warnings from gcc > without using the cast there, which defeats the whole point of > const warnings: You're not doing this right. Like it or not, "execvp()" does not take a pointer to "const char *". It takes a pointer to a constant array of _non-const_ "char *". Which is not what you have. You have a non-const array of "const char *", and as a result, you need the cast. In other words, you really need char *exec_arg[9]; or, if you can indeed set the array to be const, you can make it be char *const exec_arg[9] = { pgm, name, temp[0].name, temp[0].hex, temp[0].mode, temp[1].name, temp[1].hex, temp[1].mode, } which would work, except to avoid warnings it obviously requires that none of the strings themselves are "const" (which isn't true). IOW, you're screwed. "execvp()" really should take an argument of type "const char * const *", but it doesn't for historical reasons. Linus