Path: utzoo!utgpu!watserv1!watmath!att!linac!uwm.edu!zaphod.mps.ohio-state.edu!rpi!sci.ccny.cuny.edu!phri!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.bugs.sys5 Subject: Re: Annoying prototypes for execv* functions in V.4 Message-ID: <15028@smoke.brl.mil> Date: 31 Jan 91 17:58:58 GMT References: <3598@lupine.NCD.COM> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 21 In article <3598@lupine.NCD.COM> rfg@lupine.ncd.com (Ron Guilmette) writes: >I'm fairly sure that these declarations should be changed to: >extern int execv(const char *, const char *const *); >extern int execve(const char *, const char *const *, const char *const *); >extern int execvp(const char *, const char *const *); Unfortunately there is no "right" way to do this. Pointer-to-const has special meaning in function parameter declarations, not quite in line with the meaning in other forms of declaration. In particular, type compatibility checking will approve of passing a pointer to non-const at the "first" level, but not at the second level of referencing. Thus the common usage char *args[] = { "prog", "arg1", NULL }; execv( args[0], args ); would cause an "incompatible types for second argument" diagnostic, were (what is this "sys/" prefix?) to provide the additional "const"s that you suggest. You can legitimately consider this a technical deficiency in the C standard if you wish; we simply couldn't figure out an acceptable way to specify what one would really want for this and therefore just fixed up the spec for the top level of referencing.