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 8384659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:27:37+00:00 2026-06-09T17:27:37+00:00

I have a C++ static library that is linked in my iOS app. I

  • 0

I have a C++ static library that is linked in my iOS app. I have a void* to it in order to access some actions provided by the library from my code. The problem is that i have activated ARC on my project and it screams that in a block where the void* is called a retain cycle is generated.

the code that generates the retain cycle warning looks like below:

self.panGestureBlock = ^(UIGestureRecognizerState state, CGPoint point, CGPoint velocity) {
      [strongStreamClient onWorkerThreadDoBlock:^{
        LibGesture(libInstance, ATU_GESTURE_TYPE_PAN, GestureStateFromUIKitToLib(state), point.x, point.y, velocity.x, velocity.y); 
      }];
    };

when i pass as a parameter the libInstance pointer to the function it gives a warning like this:

Capturing ‘self’ strongly in this block is likely to lead to a retain
cycle

if i try to do something like this:

__weak void* weakLibInstance = libInstance;

    self.panGestureBlock = ^(UIGestureRecognizerState state, CGPoint point, CGPoint velocity) {
      [self onWorkerThreadDoBlock:^{
        void* strongLibInstance = weakLibInstance;
        LibGesture(strongLibInstance, ATU_GESTURE_TYPE_PAN, GestureStateFromUIKitToLib(state), point.x, point.y, velocity.x, velocity.y); 
      }];
    };

it gives a warning like below:

'__weak' only applies to objective-c object or block pointer types; type here is 'void *'

which is pretty clear.. the question is how do i get over this retain cycle? any pointers?

  • 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-06-09T17:27:39+00:00Added an answer on June 9, 2026 at 5:27 pm

    The __weak modifier only applies to pointers to Objective-C objects. You can’t use it with a void*, but in this case you don’t need to. Just remove it from the variable declaration and your code should work (assuming you don’t destroy the library instance before calling the block).

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

Sidebar

Related Questions

I have written a static library to re-use some code between iOS projects, let's
I have some code shared among multiple projects in a static library. Even with
I have a static library that may get linked into either a .exe or
I have a static library (let's call it S) that uses a category (NSData+Base64
I was given an static library (.a extension file) that I have to use
I have a Visual Studio 2008 C++ project that outputs a static library and
I have refactored some UIView sub-classes into a static library. However, when using Interface
I have a C++ program called myArchive that calls routines from a static C
I have a static library, libsqlite3.a, that i want to link to my small
I am developing static library that takes screenshots, and taking them from OpenGL applications

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.