[vlc-devel] [RFC 1/1] vlc_vector: add helpers for vectors
Romain Vimont
rom1v at videolabs.io
Thu Aug 30 12:25:17 CEST 2018
On Thu, Aug 30, 2018 at 05:30:40PM +0800, Zhao Zhili wrote:
> > > > +/**
> > > > + * Static initializer for a vector.
> > > > + */
> > > > +#define VLC_VECTOR_INITIALIZER { \
> > > > + .cap = 0, \
> > > > + .size = 0, \
> > > > + .data = NULL, \
> > > > +}
> > > ISO C++ does not allow C99 designated initializers.
> > It's a C API. C++ code should use std::vector and not this C helper.
>
> Well, nothing prevent a VLC_VECTOR(type) declared/defined in C and used in
> C++. Both g++ and clang++ support this syntax, so it's only a
> GNU extension strategy issue.
Good point. I will change to {0, 0, NULL}.
TIL than designated initializers will be supported in C++20 :)
More information about the vlc-devel
mailing list