Clang++/MSVC10 chokes on "__unaligned" in VS header files

Hi,

I built LLVM/Clang with MSVC 10.0 and tried to compile a little
program using std::vector.

In file included from main.cpp:2:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/vector:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/memory:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/xmemory:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/cstdlib:13:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/stdlib.h(343) : error: unknown type name '__unaligned'
char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
^

A google search shows clang/lib/CodeGen/MicrosoftCXXABI.cpp
knows/should know about __unaligned, or at least this part of Clang
knows about it.

Anything I can do? Thanks!

Ruben

Hi,

I built LLVM/Clang with MSVC 10.0 and tried to compile a little
program using std::vector.

In file included from main.cpp:2:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/vector:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/memory:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/xmemory:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/cstdlib:13:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include/stdlib.h(343) : error: unknown type name '__unaligned'
char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
                        ^

A google search shows clang/lib/CodeGen/MicrosoftCXXABI.cpp
knows/should know about __unaligned, or at least this part of Clang
knows about it.

I can explain that. I wrote that code.

Clang doesn't even know anything about the MSVC __unaligned keyword. The
__unaligned you saw in there was part of a comment documenting the MSVC
name-mangling scheme (which most of that file is dedicated to
implementing at the moment). MSVC will mangle __unaligned into the name;
but since Clang doesn't support __unaligned yet, Clang doesn't do that
just yet. I documented it so I'd remember how to mangle it if and when
Clang does support __unaligned.

Anything I can do? Thanks!

File a bug and write patches. Feel free to implement mangling
__unaligned in the Microsoft mangler (everything you need should be in
that file).

Chip