4

I was reading the clang documentation on reference counting, which says that “ By default in Objective-C, ARC is not exception-safe”. It proceeds to say:

A program may be compiled with the option -fobjc-arc-exceptions in order to enable these, or with the option -fno-objc-arc-exceptions to explicitly disable them, with the last such argument “winning”. In Objective-C++, -fobjc-arc-exceptions is enabled by default.

I was intrigued. Are there any other compiler options whose default change between Objective-C and Objective-C++?

Complementary question: what is difference between compiling purely Objective-C code with clang in Objective-C++ mode (*.mm files) rather than in Objective-C mode only (*.m)?

Jean-Philippe Pellet
  • 59,296
  • 21
  • 173
  • 234

2 Answers2

3

Best way is to log what clang will output from all those c language

here's some of what i have got from a obj-c++ compilation

clang++ -fobjc-arc main.mm -v

/.../
-fblocks 
-fobjc-runtime=macosx-10.7.0 
-fobjc-dispatch-method=mixed 
-fobjc-default-synthesize-properties 
-fobjc-arc 
-fobjc-arc-cxxlib=libstdc++ 
-fobjc-arc-exceptions 
-fobjc-exceptions 
-fcxx-exceptions 
-fexceptions 
-fdiagnostics-show-option 
-fcolor-diagnostics 
   /.../

As you can see those output can vary depending from where you compile it. But some of them are constants.

You should try on different c families files in order to determine what the default option are for these respective.

Hope it will help you.

Mr Bonjour
  • 3,330
  • 2
  • 23
  • 46
0

To answer the second part of your question: If you compile files in Objective-C mode rather than Objective-C++ mode, you get better support from the Static Analyzer [1]. I believe the compiler will also generate more accurate warnings in general (without using the Static Analyzer), but I cannot find/remember the source of that information.

hagi
  • 11,503
  • 3
  • 35
  • 48