• 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 bug in gcc for delta builds?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: #define bug in gcc for delta builds?


  • Subject: Re: #define bug in gcc for delta builds?
  • From: Stephen Northcott <email@hidden>
  • Date: Wed, 4 Feb 2009 19:12:05 +0700

Hi Steve,

Now I am confused. Your example showed global variables declared in the header. That's usually a bad idea since you end up with multiple copies of them and you get link errors like I showed in the response to Matt Gough. Are you saying that instead of variables being guarded by the #ifdef, you have other #defines or do you think that _FOO_ (or whatever you said you're actually using) is being redefined at some point? It sounded like you meant variables before and preprocessor #defines here.

Sorry. It seems by trying to simplify the explanation I've caused more confusion.


I have some variables in the class definition (in the header file) and some code in the .cpp file being conditionally compiled based on a set of #ifdef ... #else ... #endif statements.

The #define for those conditions is defined in the header file. The #define is simply #define DO_BAD_STUFF

And the #ifdef is simply #ifdef DO_BAD_STUFF etc.

To 'undefine' it I simply comment the #define out in the header file so it is never defined.

You mentioned data offsets before but said that it was outside the structure definition. I'm curious how you're determining the offsets of the variables.

What was happening, and I spotted this stepping through in XCode was that when the instance of the class was first created it was being created one way. Immediately after creating it I called a member function of that instance and once inside the member function it was working with the opposite definition.


One case has a block of data 40 bytes long, and the other had a block 44 bytes long.
Looking at the same instance of that class I could go up and down a level in the debugger and see the address of everything shift back and forth by 4 bytes!!


It seems very weird to me that even if there is some anomaly in my code that XCode / gcc would let that situation happen without an error. I can make a video of me doing that if it would make it any clearer..



Like I said the #define is in foo.h and only ever used in foo.cpp and foo.h. foo.cpp includes foo.h. And any where else that the class in foo is used I also include the same foo.h


So foo.h looks something like

#define _FOO_ // enable feature foo
//...
#ifdef _FOO_
//...
#else
//...
#endif

And in foo.cpp you use _FOO_ similarly _after_ #including foo.h?

Yes. Exactly.

Kind regards,
Stephen.



_______________________________________________
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: #define bug in gcc for delta builds?
      • From: Matt Gough <email@hidden>
    • Re: #define bug in gcc for delta builds?
      • From: Steve Checkoway <email@hidden>
References: 
 >#define bug in gcc for delta builds? (From: Stephen Northcott <email@hidden>)
 >Re: #define bug in gcc for delta builds? (From: Steve Checkoway <email@hidden>)
 >Re: #define bug in gcc for delta builds? (From: Stephen Northcott <email@hidden>)
 >Re: #define bug in gcc for delta builds? (From: Steve Checkoway <email@hidden>)
 >Re: #define bug in gcc for delta builds? (From: Stephen Northcott <email@hidden>)
 >Re: #define bug in gcc for delta builds? (From: Steve Checkoway <email@hidden>)

  • Prev by Date: Re: #define bug in gcc for delta builds?
  • Next by Date: How to define a preprocessor macro.
  • Previous by thread: Re: #define bug in gcc for delta builds?
  • Next by thread: Re: #define bug in gcc for delta builds?
  • Index(es):
    • Date
    • Thread