This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: GTY variable_size & documentation


Hi,

2010/7/13 Basile Starynkevitch <basile@starynkevitch.net>:
> ÂThe type machinery then provides allocators that take a parameter indicating an exact size of object being allocated (like malloc does)
>
> and the exemple should better be
>
>
> ÂThen the objects of struct sorted_fields_type are allocated in GC memory as follows, assuming n is the number of elements:
>
> Â Â Â Â field_vec = ggc_alloc_sorted_fields_type (sizeof(sorted_fields_type) + (n-1) * sizeof(tree));

I agree that these two changes would be an improvement.

> By the way, I would very much like that GCC code would assume that variable-sized struct-ures are permitted, and declare instead
> Â Â Â Âstruct GTY((variable_size)) sorted_fields_type {
> Â Â Â Â Â Â Â Â Â Âint len;
> Â Â Â Â Â Â Â Â Â Âtree GTY((length ("%h.len"))) elts[];
> Â Â Â Â Â Â Â Â};
>
> Perhaps such a transition is needed, or at least very useful, even before any transition to C++ ?

Flexible array member is a C99 feature, IIRC GCC sources require C90.

Cheers,
-- 
Laurynas


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