• 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: just C++ in xcode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: just C++ in xcode


  • Subject: Re: just C++ in xcode
  • From: Markian Hlynka <email@hidden>
  • Date: Thu, 29 Sep 2005 23:58:37 -0600

Lawrence is on the money as to the cause, I think. Sorry, I missed that!

But, having to declare x as extern in the headers is, I think, unnesessary; wouldn't that obviate the whole namespace concept?

I believe your namespace, as Lawrence says, should go in a .c file. I further believe that you shouldn't need a header file that has extern x.

Um... do preprocessor include flags solve this? (what do you call these things again?) ie

#ifndef MYFILE_H
#define MYFILE_H

... contents of header file here

#endif
//end of header file


On Sep 29, 2005, at 19:06, Lawrence Gold wrote:

On Sep 29, 2005, at 5:54 PM, Joe Kurtz wrote:


Okay everyone, we're gettin' plenty of mileage from
this. But there's just one thing I don't yet
understand. I was pretty simplistic in my example. My
code actually looks more like one of Andreas'
examples:

in foo1.h:


#include <iostream>

namespace n { int x; };
void func();


You need to declare the variable extern in the header file and then define it in ONE .c file. Remember that #include literally pastes the text of the header file into the file including it, so every file that includes foo1.h is defining a separate x.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40cs.ualberta.ca


This email sent to email@hidden


---- Quantum mechanics -- the dreams that stuff is made of.


_______________________________________________ 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: just C++ in xcode
      • From: Andreas Grosam <email@hidden>
    • Re: just C++ in xcode
      • From: Joe Kurtz <email@hidden>
References: 
 >Re: just C++ in xcode (From: Joe Kurtz <email@hidden>)
 >Re: just C++ in xcode (From: Lawrence Gold <email@hidden>)

  • Prev by Date: converting resource filename to absolute pathname
  • Next by Date: Re: Xcode beginner problem (tutorial build)
  • Previous by thread: Re: just C++ in xcode
  • Next by thread: Re: just C++ in xcode
  • Index(es):
    • Date
    • Thread