const qualifier on function return types.
Brian Gough
bjg@network-theory.co.uk
Wed Dec 19 13:20:00 GMT 2001
Lowell Johnson writes:
> cc-3303 cc: WARNING File = ../gsl/gsl_vector_double.h, Line = 78
> A type qualifier on a return type is meaningless.
>
> I searched the mailing list archive and saw a short discussion of
> this and whether it is ANSI C. I didn't see any mention of the
> reason for applying the const qualifier.
> What is the purpose of applying a const qualifier to a return
> value? Is it so that we can see the return value but not change
> it?
That was the intention, but it doesn't work. The const on those
return types is meaningless, as the compiler says.
The cause of the warnings is functions like
const gsl_vector gsl_vector_const_view (const gsl_vector * v, ..)
The logic behind the return type was to preserve constness when
creating vector views, so that a view of a "const gsl_vector *" would
also be const. It doesn't actually work because the views are
returned as structs and C doesn't preserve constness when copying
structs.
I'll have to do something about it .. it is unsatisfactory right now.
More information about the Gsl-discuss
mailing list