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

  • Home
  • SEARCH
  • 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 8463443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:27:20+00:00 2026-06-10T14:27:20+00:00

My code for registering uncaught exception handler using UncaughtExceptionHandler is as following, do you

  • 0

My code for registering uncaught exception handler using UncaughtExceptionHandler is as following, do you think there will be any potential issue?

@interface AppDelegate ()

void myHandler(NSException * exception);

@end

@implementation AppDelegate

void myHandler(NSException * exception)
{
  // ...
}

- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSSetUncaughtExceptionHandler(&myHandler);
..

Is it possible to have a more concise way to write it?

I need to use the class extension to declare prototype in order to get rid of the warning of No previous prototype for function ..

  • 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-10T14:27:22+00:00Added an answer on June 10, 2026 at 2:27 pm

    Martin’s answer is correct. However, I thought I’d elaborate just a bit, to explain why it is so.

    Your function definition:

    void myHandler(NSException * exception)
    {
      // ...
    }
    

    defines a function that will be externally visible. In other (generalized, non-technical) words, a symbol will be created in the object file so that the linker can find it, which allows other files to call myHandler.

    However, because it is supposed to be externally visible, other files are going to have to know what that function looks like. That’s where the prototype comes into play. The warning is basically saying…

    Hey, you have declared this function to be externally visible to other
    code, but I don’t see a prototype that other code can use to know
    about the function.

    So, you get a warning. It’s a good warning to have on. It helps you remember to declare prototypes for functions that you want to export.

    Now, as you discovered, you can declare a prototype, and the warning goes away. However, declaring the prototype just in the implementation file should be another warning to you. That personal warning should be:

    Do you really want this function to have external visibility, or is it just called in this compilation unit? If the function is not going to have external visibility, then there is no need to export it in the symbol table, and there is no need for a prototype that other modules can include so they know about the function.

    In that case, you can declare the function static as in Martin’s response:

    static void myHandler(NSException * exception)
    {
      // ...
    }
    

    In this context, static tells the compiler something like:

    Hey, compiler, create code for this function, and allow any code in
    this compilation unit to see the function, but do not give it external
    visibility. I don’t want the function to be called by other modules.

    In this case, even if other code declared the prototype, they would not see your function because it is “private” to the file in which it is defined.

    Since it is being used only in the local file, there is no need for a prototype, so there is no need to warn you that you don’t have one.

    Now, just as a note… You don’t need to put C functions in the @interface and @implementation sections of your code, as that does nothing. Those C functions are compiled with the exact same visibility and access whether they are inside the ObjC sections or not.

    Finally, if you want, you can disable this warning in the Xcode build settings (but now that you understand the context of the warning, I suggest leaving it on).

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

Sidebar

Related Questions

In case we are registering a java script inside the Server side code using
I am registering for Push Notification by calling the following piece of code: [[UIApplication
If I'm registering events on a UserControl in the code behind. E.g.: public partial
Code to create new form instance of a closed form using form name I
I have the following models code : from django.db import models from categories.models import
Using ASP.Net 2.0 and IIS 6 I enabled compression by extending IHttpModule and registering
I have built ffmpeg for Android using the code and method described at https://github.com/halfninja/android-ffmpeg-x264
I am working with some test code to create Visio documents. I am using
I have a section of code like the following: ---- file.php ---- require_once(mylib.php); function($a,$b)
I'm registering a receiver to capture the ConnectivityManager.CONNECTIVITY_ACTION in code i.e. I am not

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.