[LLVMdev] Question about variable sized arrays
Robin Sommer
robinsommer at web.de
Wed Feb 25 18:09:13 PST 2009
I'd like to represent strings "Pascal-style" with a length field
followed by the actual bytes. Reading the reference manual, I think
using a zero-length array should work in a struct like this:
{ i32, [0 x int8] }
However, I get a problem with referencing constants. The following
code doesn't compie:
@foo = constant { i32, [3 x i8] } { i32 3, [3 x i8] c"foo" }
define void @main( { i32, [0 x i8] }* %ptr) {
store { i32, [3 x i8] }* @foo, { i32, [0 x i8] }** %ptr
}
llvm-as reports:
Can't store '{ i32, [3 x i8] } *' into space of type '{ i32, [0 x i8] } *'
I'm wondering what the right way to do this is? I suppose I could
cast the pointer but is that really necessary? I'm pretty new to
LLVM so please forgive me if I'm missing something obvious ...
Thanks a lot!
Robin
More information about the llvm-dev
mailing list