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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:43:51+00:00 2026-06-08T23:43:51+00:00

There is something that I fundamentally don’t understand because I cannot for the life

  • 0

There is something that I fundamentally don’t understand because I cannot for the life of me get this to work. I want to create a macro that extends NSLog(NSString *format, ...). Here is what I came up with:

NSLogExtensions.h

#define DebugLog(debugMode, format, ...) MyDebugLog(debugMode, [[NSString stringWithFormat:@"<%@> (Line %d): ", NSStringFromClass([self class]), __LINE__] stringByAppendingString:format], ##__VA_ARGS__)

@interface NSLogExtensions : NSObject

@end

NSLogExtensions.m

#import "NSLogExtensions.h"

@implementation NSLogExtensions

void MyDebugLog(bool debugMode, NSString *format, ...) {
    va_list(argumentList);
    va_start(argumentList, format);
    if (debugMode) {
        NSLogv(format, argumentList);
    }
    va_end(argumentList);
}

@end

I expected to be able to include the NSLogExtensions header file and then be able to use the macro, but I receive the GCC implicit function declaration warning still.

  • 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-08T23:43:53+00:00Added an answer on June 8, 2026 at 11:43 pm

    The DebugLog macro uses the function MyDebugLog, therefore you must add the prototype

    void MyDebugLog(bool debugMode, NSString *format, ...);
    

    to NSLogExtensions.h. Then it compiles without warnings.

    BUT your solution has one (in my opinion) great disadvantage compared to the solutions that @calvinBhai refers to: Even if you switch off logging by setting debugMode to false, the DebugLog macro will evaluate all arguments and call MyDebugLog. With the other solutions, the preprocessor will remove everything if logging is disabled.

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

Sidebar

Related Questions

There is something that I really don't understand with the HttpListener. The code below
I'm beginning and there is something that I don't understand with pointers. I have
cgi.escape seems like one possible choice. Does it work well? Is there something that
I am using the CodeIgniter DataMapper ORM, but there is something that I don't
there is something that I miss about the cc-NUMA architecture and the need to
If there's something that everybody hates about Magento it's endlessly configuring your modules before
I am playing with the .net remoting features and there is something that I
I am trying some things with JSON and PHP and there is something that
math.h is not really a documentation. Is there something else that will describe these
I am playing a bit with fork/vfork functions, and there is something that is

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.