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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:50:27+00:00 2026-05-25T17:50:27+00:00

I almost finishing a clean NSLog with this code: #define NSLog(FORMAT, …) printf(%s\n, [[NSString

  • 0

I almost finishing a clean NSLog with this code:

#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, __VA_ARGS__] UTF8String]);

This work fine if I do this:

 NSLog(@"Show %@ message", @"this");

But, will fail if I user it

 NSLog(@"One argument");

because __VA_ARGS__ is nothing, so it produce

 printf("%s\n", [[NSString stringWithFormat:@"One argument",] UTF8String]);

So, the problem is the comma. Because this is macro, __VA_ARGS__ is nothing. So I can’t do things like __VA_ARGS__==nil because will produce ==nil and will fail.

The question is simple: What to do when __VA_ARGS__ is nothing? Or only use comma when have more arguments.

  • 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-25T17:50:28+00:00Added an answer on May 25, 2026 at 5:50 pm

    Use this code (notice the ## part):

    #define NSLog(FORMAT, ...) fprintf(stderr, "%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This can be so easy to a people who know. I am almost finishing
Almost 5 years ago Joel Spolsky wrote this article, The Absolute Minimum Every Software
( Almost exact duplicate of Keeping original format POST passing through AWK submitted by
Almost all of the Delphi code I have read has all the class type
Almost every project that I work will have some sort of tab delimited file
Almost the same question as this one here: What's the easiest way to grab
I've almost got it, but it doesn't quite work. I'm trying to load the
Almost all of my text in page look like this in IE7 Structure: <div>
This may seem trivial but every example I've ever seen of ADO.net almost always
Almost solved this, but it seems I'm not allowed to match with variables inside

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.