• 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: Steve Checkoway <email@hidden>
  • Date: Wed, 4 Feb 2009 03:36:59 -0800


On Feb 4, 2009, at 3:28 AM, Matt Gough wrote:

if you declare globals this way, aren't they unique to each compilation unit?

i.e if bar.cpp and roo.cpp both #include foo.h then they both refer to globals called A but they are in different locations (and hence not the same A)


Nope, they're the same A and you get an error:

[dualg5:~/temp] steve$ cat foo.h
int A = 1;

[dualg5:~/temp] steve$ cat bar1.cpp
#include "foo.h"
int getA() { return A; }

[dualg5:~/temp] steve$ cat bar2.cpp
#include <cstdio>
#include "foo.h"
int getA();
int main()
{
	A = 5;
	printf( "%d %d\n", A, getA() );
	return 0;
}

No you might expect it to print "5 1" but actually it's an error.
[dualg5:~/temp] steve$ g++ bar1.cpp bar2.cpp
ld: duplicate symbol _A in /var/folders/M1/M1WmohhpE7CR4qhrVy2-0U++ +yc/-Tmp-//ccQURsZQ.o and /var/folders/M1/M1WmohhpE7CR4qhrVy2-0U+++yc/- Tmp-//ccUxyo7j.o
collect2: ld returned 1 exit status



-- Steve Checkoway

    "Anyone who says that the solution is to educate the users
    hasn't ever met an actual user." -- Bruce Schneier




Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >#define bug in gcc for delta builds? (From: Stephen Northcott <email@hidden>)
 >Re: #define bug in gcc for delta builds? (From: Andreas Grosam <email@hidden>)
 >Re: #define bug in gcc for delta builds? (From: Stephen Northcott <email@hidden>)
 >Re: #define bug in gcc for delta builds? (From: Matt Gough <email@hidden>)

  • Prev by Date: Re: #define bug in gcc for delta builds?
  • Next by Date: Re: XCode built project crash related to .o files and p_threads?
  • 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