This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL 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: gsl_vector_const_view: pointer to constant or constant pointer


> It's not possible to initialise the struct element with this form in
> ANSI C (although it is possible in gcc).  This is why the const'ing is
> done at a higher level in a wrapper.

I found this out later, when I tried and considered some of the
alternatives and I think I discovered some of the the reasons for the gsl
vector setup.

Is it correct that the definition
typedef struct
{
  const gsl_vector *vector;
} gsl_vector_const_view;
would have the advantage that gsl_vector_const_view s can be initialized
and reassigned but the disadvantage that memory is allocated for the
vectors in the views and will need to be freed after use?

I ended up changing to non-const gsl_vector_view and casting the const
from my arrays, as Joohnas Pihlaja suggested. The other solution I could
think of was sticking to const double * s and creating the
gsl_vector_const_view only last minute when I need it.




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