Compiling As Obj-C or Obj-C++ On Windows

I have some C++ source files that mix in small bits of Obj-C. On the Mac, these files are marked to be compiled as Obj-C++. Looking at the clang help, it seems that the option for that is "-ObjC++". However, when I add that in Additional Options I get an error message:

: error : invalid integral value 'bjC++' in '-ObjC++'

I see this same message if I put "-Xclang" in front of "-ObjC++".

Is there a way to get the code to compile as Obj-C++ on Windows?

Regards,
Eric Mader

This is a horrible hack, but try adding:
-Xclang -x -Xclang objc++

If your files end in .mm, we will assume they are Obj-C++ by default.

Basically the clang-cl driver does not accept the same set of command line flags that the gcc-style driver accepts because there are conflicts around some commonly used options (-MD, for example). We make gcc-style flags available in clang-cl on an as-needed basis assuming there are no conflicts. Understandably, it is really confusing to users to have to understand two sets of flags and it might be worth revisiting that decision.

The -Xclang flag is a workaround that bypasses both the gcc-style and cl-style flags processing and directly accesses the clang -cc1 command line flag set, which is yet again different from either of the first two.

Hi Reid,

Thanks for the explanation. The hack didn’t seem to work…

Regards,
Eric