[LLVMdev] variable sized array

Eugene Toder eltoder at gmail.com
Fri Apr 23 14:37:00 PDT 2010

uint64_t MemberOffsets[];

is a C99 way of doing it (and the only standard way), but it's not a legal C++.


On Fri, Apr 23, 2010 at 10:31 AM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Yuanfang,
>> just a quick question, in llvm::TargetData,
>> uint64_t MemberOffsets[1];  // variable sized array!
>> MemberOffsets has two elements, why it's variable sized ?
> when a StructLayout object is allocated (in TargetData::getStructLayout),
> extra memory is allocated, more than that given by the size of the type.
> The extra memory is interpreted as being part of the MemberOffsets array,
> and is used for storing additional member offsets beyond the first one.
> This kind of trick generates warnings with gcc-4.5.  Maybe it can be done
> better.  I thought you were supposed to use
>   uint64_t MemberOffsets[];
> but perhaps I am mistaken.
> Ciao,
> Duncan.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list