[LLVMdev] What's the meaning of [0 x sbyte*]?

Chris Lattner sabre at nondot.org
Mon Aug 16 20:12:33 PDT 2004


On Tue, 17 Aug 2004, [gb2312] ÏÄÒ»Ãñ wrote:

> When I compiled sendmail v8.11.6 with LLVM 1.2, I found some variables with
> strange type, such as:
> %sys_errlist = external constant [0 x sbyte*]           ; <[0 x sbyte*]*> [#uses=3]
>
> %tmp.24 = getelementptr [0 x sbyte*]* %sys_errlist, long 0, long %tmp.23                ; <sbyte**> [#uses=1]

> What is the meaning of [0 x sbyte*]?
> A pointer with the type of [0 x sbyte*]* is a void pointer?

Zero length arrays for globals usually occur when the source program
contains something like this:

extern int X[];

Because we don't know the length of X, we give it an LLVM type of [0 x int].

When the linker resolves X with it's definition, it should change to the
correct length.  sys_errlist is defined by libc, which is why you're not
seeing a definition.

Hope this helps,

-Chris

-- 
http://llvm.org/
http://nondot.org/sabre/





More information about the llvm-dev mailing list