This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC/RFA] print arrays with indexes
> In fact, C99 allows:
> int A[3] = { [1] = 2 };
>
> GNU C has supported it for a while, I think. I don't think it works
> for C++.
Aha! Thanks for the tip.
> So, yes, a language method would be good.
Ok, how about calling it la_print_array_index? The current language_defn
structure already la_printchar and la_printstr (no "_" between print and
the object name), but I think using underscores is that much clearer in
this case.
void (*la_print_array_index) (struct value *index_value,
struct ui_file *stream,
int format,
enum val_prettyprint pretty);
I'll then define a new LA_PRINT_ARRAY_INDEX macro
#define LA_PRINT_ARRAY_INDEX (index_value, stream, format, pretty) \
(current_language->la_print_array_index(index_value, stream, format, pretty))
> > (gdb) set/show print array-indexes
> >
> > With a default of "off", to preserve the current behavior.
>
> I suppose we've got to :-) I'd turn it on, that's for sure.
There is also Jim's suggestion which has some merits. I'm more of
an all or nothing kind of guy, so I prefer the approach I've chosen,
but I am flexible.
> Afraid I haven't time to look at the patch just now. I'll be back.
Sure. Thanks for the early feedback.
--
Joel