Daniel Veillard <veillard(a)redhat.com> wrote:
...
> +int vethCreate(char* veth1, int veth1MaxLen,
> + char* veth2, int veth2MaxLen)
> +{
> + int rc = -1;
> + const char *argv[] = {
I think Jim insists on having const char const * [], but I bet he will explain
this better than me :-)
> + "ip", "link", "add", veth1, "type",
"veth", "peer", "name", veth2, NULL
You're right that I encourage the "const correct" approach ;-)
To tell the compiler (and more importantly, the reader) that you
have a const array of const strings, you'd declare it like this:
const char *const argv[] = {
or, equivalently, the const can go after the type name of "char":
char const *const argv[] = {
However, argv is one place where it pays to relax const-correctness
guidelines, at least in C, because so many interfaces require non-const
"char **argv" pointers. IMHO, it's better to avoid const altogether in
this limited case than to be forced to litter the code with ugly and
dangerous const-adjusting casts to accommodate "correctness".