• 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
Why Is NSLog a No-Op?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why Is NSLog a No-Op?


  • Subject: Why Is NSLog a No-Op?
  • From: Thomas Wetmore <email@hidden>
  • Date: Sat, 19 Dec 2009 18:18:46 -0500

Xcoders,

I've reached an impasse on something that seems trivial. I am Running Xcode 3.2.1 on Mac OS X 10.6.2 with "Overview" equal to "10.6|Debug|i386" on a 24" iMac 2.66 GHz Intel Core 2 Duo.

I have a foundation command line tool that calls a static cocoa library. Both were built with the same "Overview."

When running or debugging the program all calls to NSLog in the command line project's code work, but all calls to NSLog from the static library code are no-ops.

NSLog is a macro defined in NSObjCRuntime.h as ...

FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2);
FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0);

and NS_FORMAT_FUNCTION is a macro defined in NSObjCRuntime.h as ...

#if !defined(NS_FORMAT_FUNCTION)
   #if (__GNUC__*10+__GNUC_MINOR__ >= 42) && (TARGET_OS_MAC || TARGET_OS_EMBEDDED)
	#define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A)))
   #else
	#define NS_FORMAT_FUNCTION(F,A)
   #endif
#endif

(At this point I will not pretend that I understand what __attribute__ means).

I put the following code in static library code at a couple of the points where I call NSLog:

	int gnuc = __GNUC__;
	int gnucminor = __GNUC_MINOR__;
	int target_os_mac = TARGET_OS_MAC;
	int taget_os_embedded = TARGET_OS_EMBEDDED;

When I check these values with the debugger I discover what I think is expected:

__GNUC__           == 4
__GNUC_MINOR__     == 2
TARGET_OS_MAC      == 1
TARGET_OS_EMBEDDED == 0

which, at least I believe, means that NSLog in the library should not be a no-op.

I have compared all my build settings for the command line program with the static library and they agree in all places where they should.

Checking google there were some suggestions that when NSLog is not working to try restarting the computer. Which I did to an interesting effect. Now the FIRST and only the first call to NSLog issued from within the static library works!

Any thoughts, explanations or advice would be appreciated.

Tom Wetmore, Chief Bottle Washer, DeadEnds Software
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Why Is NSLog a No-Op?
      • From: Quincey Morris <email@hidden>
    • Re: Why Is NSLog a No-Op?
      • From: Jens Ayton <email@hidden>
  • Prev by Date: Warnings for undeclared methods?
  • Next by Date: Re: Why Is NSLog a No-Op?
  • Previous by thread: Re: Warnings for undeclared methods?
  • Next by thread: Re: Why Is NSLog a No-Op?
  • Index(es):
    • Date
    • Thread