[cfe-dev] Multi-dimensional arrays

Antoine Trouve trouve at isit.or.jp
Wed Dec 5 20:00:28 PST 2012


Le H.24/12/06 à 11:50, Richard Smith <richard at metafoo.co.uk> a écrit :

> On Wed, Dec 5, 2012 at 6:23 PM, TROUVE Antoine <trouve at isit.or.jp> wrote:
> Hello everybody
> 
> I would like to know how to access to all the dimensions of an array with more than one dimension from its Decl object
> In other words, if I have the type "int[42][51]", I would like to get both the "42" and the "51".
> 
> I figured out how to do so with a single-dimension using an ASTContext, but not for multiple dimensions yet.
> 
> Use getAsConstantArrayType to get the ConstantArrayType* and extract the first dimension. Then, use getElementType() on the ConstantArrayType to get the element type, and use getAsConstantArrayType on that. Lather, rinse, repeat as needed. 

That is obvious once you're told. Thank you very much !





More information about the cfe-dev mailing list