On Mon, Jul 21, 2003 at 11:24:43AM -0700, Tim Kientzle wrote:
> Chad David wrote:
> >I assumed it was obvious that you could copy the data, but I believe
> >the intent of the original question was to find an alternative. As
> >far as I know there isn't one. A const is a const, except in C++.
>
>
You know, my own thinking made me figure this one out:
% cat exec.c
#include
#include
#include
int main(int argc, char *const argv[], char *const envp[]) {
char *const execargv[] = { _PATH_BSHELL, NULL };
execve(_PATH_BSHELL,execargv,NULL);
return 0;
}
% cc -fwritable-strings -Wcast-
In a message written on Mon, Jul 21, 2003 at 11:24:43AM -0700, Tim Kientzle wrote:
> I was hoping that someone knew a standard way to
> say "yes, I really do mean to cast away that const,"
> akin to C++ const_cast.
I'm missing something here. You can do that, but you can't do that
with say "-Wcas
Chad David wrote:
I assumed it was obvious that you could copy the data, but I believe
the intent of the original question was to find an alternative. As
far as I know there isn't one. A const is a const, except in C++.
Yes, the intent was to find a way to avoid copying the data.
I was hoping th
On Mon, Jul 21, 2003 at 01:23:21PM -0400, Leo Bicknell wrote:
> In a message written on Mon, Jul 21, 2003 at 11:15:38AM -0600, Chad David wrote:
> > Try cc -Wwrite-strings -Wcast-qual exec.c.
> >
> > You cannot simply cast away a const.
>
> Grumble, will someone give me all the warnings you want
In a message written on Mon, Jul 21, 2003 at 11:15:38AM -0600, Chad David wrote:
> Try cc -Wwrite-strings -Wcast-qual exec.c.
>
> You cannot simply cast away a const.
Grumble, will someone give me all the warnings you want turned on so I
can work around all of them? :)
% cat exec.c
#include
#i
On Mon, Jul 21, 2003 at 12:57:35PM -0400, Leo Bicknell wrote:
> In a message written on Mon, Jul 21, 2003 at 08:53:53AM -0700, Tim Kientzle wrote:
> > Actually, this example passes -Wall if you declare
> > "execargv" as simply "char *[]". However, I'm looking
> > for something that passes gcc -Wwr
In a message written on Mon, Jul 21, 2003 at 08:53:53AM -0700, Tim Kientzle wrote:
> Actually, this example passes -Wall if you declare
> "execargv" as simply "char *[]". However, I'm looking
> for something that passes gcc -Wwrite-strings, which this
> example does not.
% cat exec.c
#include
#
Leo Bicknell wrote:
In a message written on Sun, Jul 20, 2003 at 02:13:52PM -0700, Tim Kientzle wrote:
If I declare argv as "const char *",
then the call to execve() warns about
"incompatible pointer type" for the
second argument.
Almost, but the other order is important here, this passes gcc -Wall
In a message written on Sun, Jul 20, 2003 at 02:13:52PM -0700, Tim Kientzle wrote:
> If I declare argv as "const char *",
> then the call to execve() warns about
> "incompatible pointer type" for the
> second argument.
Almost, but the other order is important here, this passes gcc -Wall:
#include
I can find no way to call execve
that actually compiles without warnings.
If I use:
char *argv[2];
argv[0] = _PATH_BSHELL;
argv[1] = NULL;
execve(_PATH_BSHELL,argv,environ);
then the first assignment is "discarding
qualifiers".
If I declare argv as "const char *",
then the call to execve()
11 matches
Mail list logo