[LLVMdev] [cfe-dev] __builtin_va_list different on targets

Wenhan Gu nowar100 at gmail.com
Mon May 23 00:43:18 PDT 2011


Thanks for your answer very much.

I wonder for what reason does ARM use *void ** but X86 use *char ** ?
Seems ARM uses void * since its spec said that.
But X86? I cannot find any reason or spec to specify why X86 uses char *,
not void * directly?

Could anyone give me some hints?
Thanks a lot.

2011/5/23 John McCall <rjmccall at apple.com>

> On May 22, 2011, at 8:49 PM, Wenhan Gu wrote:
>
> I know __builtin_va_list is target-specific, and
> ARM has typedef void* __builtin_va_list;
> X86 has typedef char* __builtin_va_list;
>
> It seems they can be treated as the same prototype,i.e.. void*, at the
> header level.
> What I want to ask is:
>
> If I write a program use "typedef *void** __builtin_va_list" on X86, and
> run it.
> Would I face any problem on run-time?
>
>
> C guarantees that void* and char* have compatible representations, so
> as long that's the only difference, you won't have runtime problems.
> You can obviously have compile-time problems, though:  for example,
> in C, if va_list is a void*, then it can be implicitly converted to any
> pointer
> type instead of (as with char*) only explicitly converted;  and in C++, you
> can get different manglings, which is actually how we found out that our
> ARM target was misdeclaring it.  But otherwise it should be fine, as long
> as that's the only difference.
>
> However, other targets may have more complicated differences than
> just void* vs. char*.
>
> John.
>



-- 
Best regards,
Wen-Han
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110523/5b4417f5/attachment.html>


More information about the llvm-dev mailing list