Re: Newbie Question - #include scope
Re: Newbie Question - #include scope
- Subject: Re: Newbie Question - #include scope
- From: email@hidden
- Date: Wed, 10 Dec 2008 14:26:53 -0500
You should put your includes at the top of each file in which you'll
be using the included file's members.
Quoting Gil Dawson <email@hidden>:
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