Unix Programming - execve and char const *

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2004 > execve and char const *





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author execve and char const *
Christoph Bartoschek

2004-05-18, 9:18 am

Hi,

execl() takes for the argument list a NULL terminated list of "char const *"
pointers.

execve() however takes a "char *const argv []" for the argument list. Is
there a reason that it does not take a "char const * const argv[]" similar
to execl()?

Greets
Christoph
Bjorn Reese

2004-05-18, 2:50 pm

On Tue, 18 May 2004 10:21:50 +0200, Christoph Bartoschek wrote:

> execve() however takes a "char *const argv []" for the argument list. Is
> there a reason that it does not take a "char const * const argv[]" similar
> to execl()?


From SUSv3 [1]

"The statement about argv[] and envp[] being constants is
included to make explicit to future writers of language
bindings that these objects are completely constant. Due to
a limitation of the ISO C standard, it is not possible to
state that idea in standard C. Specifying two levels of const-
qualification for the argv[] and envp[] parameters for the
exec functions may seem to be the natural choice, given that
these functions do not modify either the array of pointers
or the characters to which the function points, but this
would disallow existing correct code. Instead, only the
array of pointers is noted as constant."

[1] http://www.opengroup.org/onlinepubs...tions/exec.html

--
mail1dotstofanetdotdk

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com