bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Support C++11 Objective-C++ in objc_.* targets

Open mrdomino opened this issue 11 years ago • 8 comments

I want to compile a target that contains some Objective-C files and some Objective-C++ files (conventionally ending in .mm). For the latter, I want to specify -std=c++11. If I add that to objccopts, my Objective-C++ files compile, but clang dies on my Objective-C files with:

error: invalid argument '-std=c++11' not allowed with 'C/ObjC'

mrdomino avatar Aug 09 '15 00:08 mrdomino

Damien, could you help direct this to the right person?

dslomov avatar Aug 10 '15 11:08 dslomov

Peter: do you have some comment on that?

damienmg avatar Aug 10 '15 14:08 damienmg

We don't have the ability to add C++ opts yet. We are aware of the problem.

Sigh... file a bug please?

Cheers, Dave

On Mon, Aug 10, 2015 at 7:18 AM, Damien Martin-Guillerez < [email protected]> wrote:

Peter: do you have some comment on that?

— Reply to this email directly or view it on GitHub https://github.com/google/bazel/issues/366#issuecomment-129470219.

dmaclach avatar Aug 10 '15 15:08 dmaclach

Until this is fixed, my planned workaround is to have my objc++ in a separate objc_library called mylib_objcc that specifies -std=c++11. This also means I need to take that out of my global copts and rely on the c++ toolchain providing it instead, which is... reasonable, I suppose.

mrdomino avatar Aug 10 '15 20:08 mrdomino

Any update on this issue?

adamhowardprice avatar May 03 '16 17:05 adamhowardprice

Alternatively, allowing .m / .mm files in cc_library could work. Right now, it is possible to build an ObjC/ObjC++ library providing the files end with .c or .cpp and the -ObjC or -ObjC++ flags are passed when compiling. This way, cross platform programs don't have to specify a special set of rules to use the objc_library from a cc_library or cc_binary dependency.

Orphis avatar May 03 '16 20:05 Orphis

It seems like this is now fixed in objc_library, when passing copts = ["-ObjC++","-std=c++11"]

AlexTalks avatar May 18 '16 20:05 AlexTalks

Consider separating out objc_library targets into srcs of different types, if their copts need to differ? These can be later recombined as a single objc_library which depends on both...

Per-language per-target copts strikes me as scaling poorly.

c-parsons avatar Jun 15 '16 18:06 c-parsons