0
votes

I'm trying to compile a fairly simple "hello world" program using stl headers with clang on windows, and I'm unable to do that.

I've compiled Clang 3.1 from repository using VC11 Beta without problems. Now I'm trying to use the already compiled Clang to compile a "hello world" sample using the VC11 headers but I get a bunch of errors which seems to show Clang is getting lost with some macro magic for simulated variadic templates on VC11, although I'm not making direct use of this macro magic.

My include directories:

  • C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include
  • C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include
  • C:\Program Files (x86)\Windows Kits\8.0\Include\um
  • C:\Program Files (x86)\Windows Kits\8.0\Include\shared
  • C:\Program Files (x86)\Windows Kits\8.0\Include\winrt

I get errors like:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xstddef:1094:24: error: '_Nil' does not refer to a value

And a bunch of others related to macros.

Was someone able to overcome this macro issues? Is there a problem with clang preprocessor on expading this macros?

2
Macros aside, this won't work as Clang doesn't handle __declspec.ildjarn
@ildjarn So I think the headers aren't full of __declscpec, with VC10 I was able to compile the same source using iostream header (and other headers from VC10) without problems.pepper_chico
@Chico: That's because VC10 understands __declspec. Clang does not.Nicol Bolas
@NicolBolas sorry, I meant to say "with VC10 headers". Assume same configuration as the problem presented, only changing compiler versions, and I don't get those problems.pepper_chico

2 Answers

1
votes

Microsoft's C++ headers involve extensions and idiosyncrasies that aren't yet supported. Clang can build programs with the C headers on Windows, but not yet the C++ headers.

Since the C runtime works you might be able to use a different C++ standard library that only relies on the C runtime. I haven't tried it, but perhaps libc++ can be used that way.

0
votes

I am very sure you will not be able to use clang for compiling some headers like C:\Program Files (x86)\Windows Kits\8.0\Include\winrt. The reason is because Windows 8 brings a C++ version with some extension. This version has be called C++/CX.

Some of the extensions (like ref class) are not standard C++. I believe this is causing messages on building saying you are trying to compile some variadic templates.