• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Macro challenge with variable arguments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Macro challenge with variable arguments


  • Subject: Macro challenge with variable arguments
  • From: Graham Cox <email@hidden>
  • Date: Fri, 02 Nov 2012 13:15:54 +1100

Hi all, I'm having trouble figuring this out.

I have a logging function thus:

	void	GCLogObjCMethod( id obj, SEL selector, NSUInteger lineNumber, NSString* tag, NSString* format, ... );

I'd like to be able to wrap this using a macro that automatically supplies the object, selector, line number and 'tag' (which is usually the class name of the object) and leaves only the format and the variable arguments to be supplied. I haven't been able to come up with a way that works. Can it be done? i.e. what I want is a macro:

GCLOGOC( @"this is a format string: %@, with any number of params: %@", paramA, paramB );

and this expands to:

GCLogObjCMethod( self, _cmd, __LINE__, NSStringFromClass([self class]), @"this is a format string: %@, with any number of params: %@", paramA, paramB );

(or expands to nothing at all if logging has been turned off).

How can I define the macro so it can handle the variable parameter list?

--Graham


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Macro challenge with variable arguments
      • From: Scott Ribe <email@hidden>
    • Re: Macro challenge with variable arguments
      • From: Gwynne Raskind <email@hidden>
    • Re: Macro challenge with variable arguments
      • From: Greg Parker <email@hidden>
  • Prev by Date: Re: View-based NSTableView strange scrolling behavior.
  • Next by Date: Re: View-based NSTableView strange scrolling behavior.
  • Previous by thread: Re: View-based NSTableView strange scrolling behavior.
  • Next by thread: Re: Macro challenge with variable arguments
  • Index(es):
    • Date
    • Thread