Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6836303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:20:23+00:00 2026-05-26T23:20:23+00:00

Is there a #pragma (or otherwise some construct) to explicitly enable automatic reference counting

  • 0

Is there a #pragma (or otherwise some construct) to explicitly enable automatic reference counting (ARC) in an Objective-C (or Objective-C++) source file? Even better if the source file can cause compilation to fail if ARC is not enabled.

I’m starting to have a number of ARC-only source files that can be potentially shared with other projects. Most of these contain category methods to extend built-in classes. I just don’t want to accidentally include these in a non-ARC project and starts leaking out memory.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:20:23+00:00Added an answer on May 26, 2026 at 11:20 pm

    As far as I can tell there is no way to explicitly enable or disable ARC.

    However it is possible to detect if it is enabled. Simply add the following snippet to any file that requires ARC.

    #ifndef __has_feature
      #define __has_feature(x) 0 /* for non-clang compilers */
    #endif
    
    #if !__has_feature(objc_arc)
      #error ARC must be enabled!
    #endif
    

    More info:
    http://clang.llvm.org/docs/AutomaticReferenceCounting.html
    http://clang.llvm.org/docs/LanguageExtensions.html#__has_feature_extension

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There's a #pragma command to link in a library from the source file rather
Is there any way, via a pragma directive, to add a source file to
Main article there is a header file and a source file . After copying
I've read that there is some compiler optimization when using #pragma once which can
There are compiler options in MSVC to enable the automatic generation of instrumentation calls
Is there a pragma or debugger attribute which will allow the debugger to not
Is there a way to set a pragma disable warning for visual studio for
is there any constant or #pragma to get the time and date, when the
For some compilers, there is a packing specifier for structs, for example :: RealView
Is there some way to make c++ dlls built with diffrent compilers compatible with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.