[Windows] __uuidof support?

It seems like there is no support for the “__uuidof” operator in clang. This operator is heavily used in conjunction to COM on Windows.

Attempting to build a small Direct3D example code (attached) with “clang -v test.cpp -o test.exe” yields the following error:

test.cpp (542 Bytes)

possible sulution?

http://stackoverflow.com/questions/8868784/alternative-to-uuidof-in-c

#include <d3d11.h> + macro

#define __uuidof(NAME) IID_##NAME

could help - but not perfect

Definitely file a bugzilla issue on __uuidof, but as for plans...
patches welcome. :wink: We already have some support for
__declspec(uuid) to attach a uuid to a decl, so this would be a matter
of performing the proper lookups on an expression to find the proper
decl, see if it has the correct attribute attached to it, and pull the
GUID out of it. We don't have any support for IDL libraries, so that
would be a different situation entirely.

~Aaron

What C/C++ runtime are you trying to use, a mingw variant or one of Microsoft’s?

We support __uuidof in the Microsoft C++ ABI, but not the Itanium C++ ABI. The easiest way to use the Microsoft C++ ABI support is with the clang-cl frontend:
http://clang.llvm.org/docs/UsersManual.html#clang-cl

However, the Microsoft C++ ABI support is still really immature, so you might want to stick with mingw. In the Microsoft C++ ABI, Clang lacks support for:

  • pass by value of certain kinds of objects
  • RTTI
  • exceptions
  • debug info
  • member pointer support is a bit weak

New issue: http://llvm.org/bugs/show_bug.cgi?id=18133

Unfortunately, I don't think I will be able to improve on this myself. But
at least, it will be easier to track the progress of this issue now.

Fredrik

Thanks for the information Reid!

I am entirely new to Clang and was unknowingly targeting the Itanium ABI.
By switching to the the Microsoft ABI with clang-cl the problem went away.
:slight_smile:

Unfortunately, I instead encountered many RTTI-related compiler issues as
you mentioned. This is a bit disappointing, since it seem like neither ABI
will work for me at the time being.

My primary motivation for testing Clang was to evaluate the static
analyzer. Run-time issues like exceptions, missing debug info etc. is
therefore not a concern for me. What matters is to be able to parse/compile
the code.

Fredrik

Hi Fredrik,

You can try passing “-fno-rtti” to the driver which might help with lack of RTTI in MS ABI.