• 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
Re: #define not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: #define not working


  • Subject: Re: #define not working
  • From: Tommy Nordgren <email@hidden>
  • Date: Sat, 1 Oct 2005 23:43:18 +0200


Oct 1, 2005 kl. 11:07 PM skrev Stéphane Sudre:


On samedi, octobre 1, 2005, at 11:06 PM, Alexander Hartner wrote:


I have added the following section all over my code to use during debugging:

#ifdef DEBUG_LOG
    NSLog(@"Freeing memory for keychain: (0=Success) %d \n",sec);
#endif

The idea is that I can switch debug information on and off by either including :

#define DEBUG_LOG
#define INFO_LOG

For some reason these instructions are ignored and I never see any message on the output. When I remove the #ifdef ... #endif block and leave the NSLog statement the message is printed correctly.

Any suggestion why the ifdef / define is not processed ? The application is a Cocoa Command Line Tool, if that makes a difference.


Try:

#define DEBUG_LOG 1

This should not make any difference. The #ifdef only tests if a symbol is defined, not if the expansion is nonempty.
I've tested with the following program stub:
#import <Foundation/Foundation.h>


int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    // insert code here...
    NSLog(@"Hello, World!");
#define DEBUGLOG1
#define DEBUGLOG2 1

#ifdef DEBUGLOG1
    NSLog(@"DEBUGLOG1 defined");
#endif
#ifdef DEBUGLOG2
    NSLog(@"DEBUGLOG2 defined");
#endif
    [pool release];
    return 0;
}

The output is:
2005-10-01 23:41:49.312 Testifdef[11973] Hello, World!
2005-10-01 23:41:49.314 Testifdef[11973] DEBUGLOG1 defined
2005-10-01 23:41:49.314 Testifdef[11973] DEBUGLOG2 defined

The cause of the OP's problem must be something else, probably that the header file defining the preproccessor symbol is not included.

-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: #define not working
      • From: Scott Ribe <email@hidden>
    • Re: #define not working
      • From: Oscar Bonilla <email@hidden>
References: 
 >Re: #define not working (From: Stéphane Sudre <email@hidden>)

  • Prev by Date: Re: #define not working
  • Next by Date: Re: #define not working
  • Previous by thread: Re: #define not working
  • Next by thread: Re: #define not working
  • Index(es):
    • Date
    • Thread