Writing a weather program and I'm using a structure to keep the current weather data. Right now I have two source files - main.c and rssparse.c. rssparse contains all the functions I need to read the data.
I have the "current" structure defined in main.c as...
Then in rssparse.c I'm trying to access that in a function via -Code:.....<insert includes and other stuff here> struct weatherdata{ int temp; char *status; int humidity; int windspeed; char winddirection; float barometer; int dewpoint; int heatindex; int windchill; int visibility; } current; int main(void){ <....program goes here>
Compile and...Code:if (!strcmp(idname, "humidity")) current.humidity = atoi(value); else if (!strcmp(idname, "windspeed")) current.windspeed = atoi(value); else if (!strcmp(idname, "dewpoint")) current.dewpoint = atoi(value); else if (!strcmp(idname, "heatindex")) current.heatindex = atoi(value); else if (!strcmp(idname, "windchill")) current.windchill = atoi(value); else if (!strcmp(idname, "visibility")) current.visibility = atoi(value);
I've tried declaring the structure in rssparse in every way I can think of. extern struct current, extern current, etc. All I want to do is access the bloody structure globally!In file included from main.c:30:
rssparse.c: In function `ParseHTML':
rssparse.c:160: error: `current' undeclared (first use in this function)
rssparse.c:160: error: (Each undeclared identifier is reported only once
rssparse.c:160: error: for each function it appears in.)
main.c: At top level:
main.c:50: error: `current' used prior to declaration
So do any of you C gods know what I'm doing wrong?![]()



LinkBack URL
About LinkBacks



