»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 06-24-2003, 09:16 PM   #1 (permalink)
Registered User
 
Join Date: Jun 2003
Posts: 2
briang5 is on a distinguished road
Passing structures between files

I am trying to pass a structure between two files that are compiled independently as part of the same project.


I have two files (file1, file2) as well as an include file. Both file1 and file 2 include the include file.

include.h is the include file, and contains the following:

struct randy_struc {
char *name; //name of option i.e frequency
int value [6]; //value of option
int max_choices; //total number of values for options (20 max)
char *value_string [20]; //string that displays
} ;



In file 1, I have a definition of a member of the structure:

randy_struc
randy_option_1 = //don't change
{" Host interface ",
{3,3,3,3,3,3},
3,
{
"",
"ISA ",
"SMB ",
"None",
},
};
For now assume the structure isnt referenced by file 2, I can then compile my program error free and it works. But now I want access to the structure from file 2 so I add the following to file 2:

extern struct randy_struc; (or several derivatives of the same thing)


I end up with a compiler error message (BC4.2) of "storgae class extern is not allowed here"

Any ideas ?

briang5 is offline   Reply With Quote
Old 07-05-2003, 05:38 PM   #2 (permalink)
Registered User
 
strangerstill's Avatar
 
Join Date: Oct 2001
Posts: 1,565
strangerstill is on a distinguished road
Re: Passing structures between files

Quote:
Originally posted by briang5
But now I want access to the structure from file 2 so I add the following to file 2:

extern struct randy_struc; (or several derivatives of the same thing)


I end up with a compiler error message (BC4.2) of "storgae class extern is not allowed here"
struct randy_struc is the name of a structure type, which you already have included. Perhaps you want to reference a variable, an instance of the structure type?
strangerstill is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 04:12 AM.