This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: inconsistent 'const' in exec{l,v}.


2011/11/17 Mark Brown <bmark@us.ibm.com>:
>> i've noticed that manual describes variable number of 'const char*'
>> arguments for execl()
>> and array of non-const arguments for execv(). is it a bug or an
>> intelligent design?
>> imho it should be declared as 'const char* const argv[]'.
>
> I'll refer you to the POSIX spec (online at
> http://pubs.opengroup.org/onlinepubs/9699919799/nframe.html ) for
> how the exec* functions are specified.

C has no notion of "constant data" just that "the contents pointed to
by the pointer won't change" and "the location pointed to by this
pointer won't change" (See 6.7.5.1.3 in ISO C99).

Therefore the POSIX standard, as explained in the Open Group
description, has to choose the best option keeping in mind existing
code.

Specifying the function using "const char* const argv[]" as you
suggest would break existing code by requiring a cast and still
doesn't specify exactly what is intended by the interface and which
can't be expressed in C anyway.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]