• 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
Newbie Question - #include scope
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie Question - #include scope


  • Subject: Newbie Question - #include scope
  • From: Gil Dawson <email@hidden>
  • Date: Wed, 10 Dec 2008 11:19:08 -0800

Hi--

I am rather new to XCode (Version 2.5), still reading the User Guide.  I'm stumped by one thing I'm seeing that I'd think would be obvious.

I made up a little project to demonstrate this thing.  The project contains three files (listed below); "test.c" #includes the other two.   The first #included file declares a global variable, MyData, and sets it.  The second #included file uses that variable.  

The problem is, when I compile (command-K) the "test.c" file, the second #included file gets an error that MyData is undeclared. Why so?

I confess to an illusion that this doesn't happen all the time.  I could swear (but I cannot reproduce) that that compile went through without errors a few minutes ago, before I changed something then changed it back.  Is this possible, or should I think about changing my coffee supplier?

--Gil

//test.c
#include <test.h>
int main(void) {
if (MyData); //stub
return 1;
}
#include "testadd.c"

//test.h
int MyData = 0;

//testadd.c
void foo(void) {
if (MyData);  //<-- 'MyData' undeclared (first use in this function)
}
 _______________________________________________
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: Newbie Question - #include scope
      • From: Jeremy Pereira <email@hidden>
    • Re: Newbie Question - #include scope
      • From: Steve Checkoway <email@hidden>
    • Re: Newbie Question - #include scope
      • From: email@hidden
  • Prev by Date: Re: undefined symbols
  • Next by Date: Re: Newbie Question - #include scope
  • Previous by thread: Static and Dynamic libraries for iPhone apps ?
  • Next by thread: Re: Newbie Question - #include scope
  • Index(es):
    • Date
    • Thread