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

John McCall rjmccall at apple.com
Mon May 23 00:30:57 PDT 2011


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110523/65f5f191/attachment.html>


More information about the llvm-dev mailing list